I was asked to answer this on Quora by Quora member Paolo Anderson today.
Paolo, thanks for asking me to answer your question.
Much of it does stay classified, even if the platform is known. For instance with aircraft carriers, no big secret, but its top speed and range remain classified aspects of that platform.
Even then, some of those secrets don’t stay secret for long. Satellite and other forms of intel gathering and espionage have their place and can be effective, even if the information gathered about a platform is limited in scope.
The older systems tend to have more information out there than newer systems and capabilities. New weapons platforms in the research and development stage are highly classified. However once those systems become operational, efforts to collect intel and data on those new systems begins.
Remember the stealth bombers? Those were a big secret once upon a time. They are not such a big secret any longer, but much of their capabilities still are classified.

What does stay classified are the TT&P, or the Techniques, Tactics and Procedures in which those weapons are deployed and employed in theatre. The where, when and how. So even if the capabilities of a weapon system are known, the element of surprise can still, hopefully to some degree, be exercised.
Even then, there will be a combination of different weapon platforms used in conjunction to achieve mission success on the battlefield. Then you have the added benifit of a show of force and capability to hopefully deter future hostilities. In this case, it isn’t so much about the platform itself, and how much of it is known (numbers, capabilities, results) but the how and when it is used. Once that gets out, any enemy force, or future enemy force has to begin to consider and train other alternatives and scenarios. Then, once that happens, we continue our intel gathering on those changes in their training methods, and the cycle continues.
So things stay secret, until they are not secret any longer.
https://www.quora.com/Why-do-country-publicise-their-military-inventory-nowadays-Shouldnt-it-be-a-secret/answer/William-Stynetski
This would necessitate having to know the ships schedule and routine and possible movements of sailors from point A to B, and we haven’t even touched on watch guards or patrols yet.
Eventually, even if you brought your own, you would need food and water, unless you had some kind of plan in place to get out before those run out.
Getting out you risk being caught as well.
As a sidenote, it would not be impossible. I was fairly bored in the navy and I’ve snuck both onto my ship and onto military bases avoiding the main gate. Only difference was, I was in the military at the time and although getting killed doing so was a possibility, especially at 2am, getting caught would have been more likely and resulted in some form of disciplinary action.
William Stynetski