The navy "launched a cyber-attack against the computer network of the defensive forces in order to infiltrate the network and hack information or spread virus," the English-language Iran daily reported, quoting Rear Admiral Amir Rastegari.
Rastegari said the cyber-attack was successfully detected and blocked.
Over the past three years, Iranian industrial facilities including oil and nuclear sites, as well as communications networks and banking systems, have all come under cyber-attacks blamed on the United States and regional arch-foe Israel.
Tehran says it has developed civil and military cyber units to counter such attacks.
Naval forces of the elite Revolutionary Guards have been engaged in a military drill in the Strait of Hormuz as well as in the Gulf of Oman for the past week.Iranian military officials say the exercises are aimed at demonstrating Tehran's "defensive naval capabilities and sending a message of peace and friendship to regional countries."
Submarines are taking part in the drills in which several missile systems are being tested, Iranian media reported.
Military officials have said that the manoeuvres were not aimed at closing the strategic Strait of Hormuz waterway through which much of the world's oil supply passes.
In the past Tehran has repeatedly threatened to block the strait if its vital interests such as nuclear sites are attacked.
Israel says it has not ruled out a military strike against Iran's controversial nuclear programme, which it and the West suspect is aimed at developing atomic weapons, a charge Tehran denies.