Slashdot Mirror


Port Knocking in Action

tyldis writes "There was something called "port knocking" mentioned on Slashdot earlier, and now an implementation has sprung to life. Is this something worth pursuing?" The page is to an application called knockd which is a simple proof of concept with hard coded knock sequences. Really interesting stuff.

107 of 430 comments (clear)

  1. one of many by bangular · · Score: 3, Interesting

    There are actually about 5 other known port knocking implementations. And it's such an easy thing to do, I'm sure many others have written their own private implemenations.

    1. Re:one of many by Anonymous Coward · · Score: 4, Funny

      Actually I counted 11 other port knocking implementations. Really I did. Can I get modded +4 also?

    2. Re:one of many by jacquesm · · Score: 2, Funny

      port knocking is like having a deliberate hole in
      your carefully constructed secure zone.

      I'm going to stay a mile away from anything that
      brings on board a 'knocker'...

      I'd hate to get knocked up.

    3. Re:one of many by PacoTaco · · Score: 2, Funny

      Well, someone needs to come up with a better name. I feel like I should be saying "shut up Beavis" whenever somebody mentions it.

    4. Re:one of many by tverbeek · · Score: 4, Insightful
      port knocking is like having a deliberate hole in your carefully constructed secure zone.

      Well, yes. That's the point: to enable access to a secured system. It's often a necessary evil. The issue is that most people implement these deliberate holes by leaving certain ports open to simple direct access. They're easy to find, and not all that difficult to exploit. Adding a layer of obscurity and another layer of security on those holes - in effect putting a concealed combination lock on them - would be a more secure way of doing that.

      --
      http://alternatives.rzero.com/
    5. Re:one of many by jacquesm · · Score: 2, Insightful

      In practice though, once the system becomes
      automated it no longer is the user that sets
      it up but some - untrusted - application like
      say the next cool file sharing program. Next
      a bug is discovered and *bang* millions of
      previously firewalled machines are suddenly
      wide open.

    6. Re:one of many by uberdave · · Score: 2, Insightful

      The point for me would be to punch a hole in a draconian acceptable use policy. Many broadband providers to not permit you to run servers, and frequently they will run portscans to find violators. With this technique, they could portscan away, and I'd still be able to access files on my home machine from outside. Pesky broadband monopolies.

    7. Re:one of many by dillon_rinker · · Score: 2, Interesting

      So your theory is that programs are MORE secure when they have LESS security features?

      I suppose that having passwords on user accounts is silly, too, because some rogue program could log keystrokes and post them to the web.

    8. Re:one of many by aceat64 · · Score: 2

      The underlying service (like SSH) is still secure, it's just another LAYER of security. Did you even bother to find out how port knocking works?

    9. Re:one of many by Fermier+de+Pomme+de · · Score: 2, Insightful

      Programs are often more secure when they have fewer features of any kind. Pick something simple and do it well.

    10. Re:one of many by blackbear · · Score: 2, Insightful

      So your theory is that programs are MORE secure when they have LESS security features

      Actually, programs are MORE secure when they have LESS features. period. Security features are still features. If implemented incorrectly they can weaken security instead of enhance it. Complexity increases the probability of vulnerability.

      I suppose that having passwords on user accounts is silly, too, because some rogue program could log keystrokes and post them to the web.

      In some situations, that is exactly correct. It depends very much on the application. In some very high security situations, passwords are considered too weak to rely on. In those cases "something you have" and "something you are" are often used as two factor (strong) authentication.

      And yes, I am an information security professional. (but not a lawyer.)

    11. Re:one of many by Anonymous Coward · · Score: 5, Informative
  2. How do you transcribe... by JesseL · · Score: 5, Funny

    "shave and a haircut" into port numbers?

    --
    "Prefiero morir de pie que vivir siempre arrodillado!"
    1. Re:How do you transcribe... by winkydink · · Score: 4, Funny

      I dunno. How many ports can you knock on with two bits?

      --

      "I'd rather be a lightning rod than a seismometer." -Ken Kesey

    2. Re:How do you transcribe... by Dwedit · · Score: 2, Informative

      In QBASIC:

      s$ = "shave and a haircut"

      FOR i = 1 TO LEN(s$) STEP 2
      IF i LEN(s$) THEN
      PRINT ASC(MID$(s$, i, 1)) * 256 + ASC(MID$(s$, i + 1, 1))
      ELSE
      PRINT ASC(MID$(s$, i, 1))
      END IF
      NEXT

      Output:
      29544, 24950, 25888, 24942, 25632, 24864, 26721, 26994, 25461, 29544, 24950, 25888, 24942, 25632, 24864, 26721, 26994, 25461, 29544, 24950, 25888, 24942, 25632, 24864, 26721, 26994, 25461, 116

    3. Re:How do you transcribe... by Anonymous Coward · · Score: 2, Informative

      2093, 1568, 1568, 880, 988, 1568, the frequency of the pitch of the notes.

    4. Re:How do you transcribe... by nacturation · · Score: 2, Funny

      I dunno. How many ports can you knock on with two bits?

      Four, of course!

      --
      Want to improve your Karma? Instead of "Post Anonymously", try the "Post Humously" option.
    5. Re:How do you transcribe... by Hanji · · Score: 4, Funny
      $perl -e 'print join(",",unpack("s*","shave and a haircut"))."\n"'
      29544,24950,25888,24942,25632,24 864,26721,26994,25461
      Q-BASIC, BAH
      --
      A Minesweeper clone that doesn't suck
    6. Re:How do you transcribe... by julesh · · Score: 2, Insightful

      Obviously network byte order (big endian) would be most sensible.

      Am I the only one who's noticed that these perl implementations all contain a bug which the original QBASIC one didn't - if there's an odd number of characters the last one is ignored, whereas it should really be counted somehow.

      Although the QBASIC implementation put it in the least significant byte; I'd be tempted to put it into the most significant byte, effectively padding the end of the string with an extra zero.

  3. Knock Knock by Anonymous Coward · · Score: 4, Funny

    You can keep on knockin' but ya can't come in

  4. Port to MIDI interface by Black+Art · · Score: 3, Funny

    So how do we map musical notes to port numbers?

    I want to get "shave and a haircut" ported over to the new protocol.

    --
    "Trademarks are the heraldry of the new feudalism."
  5. Great for warez... by danielrm26 · · Score: 5, Interesting

    I can see this being used quite extensively in the warez arena. It'd be pretty easy to give out the "key" to clients who are allowed access, while any ISP scanning for FTP servers, for example, would find nothing open.

    --
    dmiessler.com -- grep understanding knowledge
    1. Re:Great for warez... by selfabuse · · Score: 2, Insightful

      Along the same lines, it would be useful to us non-warez folk that run servers at home that are for personal use, but have broadband that disallows servers in the AUP.

    2. Re:Great for warez... by caluml · · Score: 4, Informative

      I fear the ISP might just watch for large amounts of data spewing out on tcp/20.

    3. Re:Great for warez... by KingOfBLASH · · Score: 2, Insightful
      I can see this being used quite extensively in the warez arena. It'd be pretty easy to give out the "key" to clients who are allowed access, while any ISP scanning for FTP servers, for example, would find nothing open.

      <tongue in cheek>
      If you had an ISP that was port scanning for open FTP servers on port 20, why not just move your port to another port with well known use for home users, like 135?
      </tongue in cheek>

    4. Re:Great for warez... by gnu-generation-one · · Score: 2, Funny

      "I can see this being used quite extensively in the warez arena."

      Shhhh.... Don't mention the trojans.

    5. Re:Great for warez... by S.Lemmon · · Score: 2, Interesting

      Well, just running on a non-standard port is usually enough for that. Better still, why not just firewall off whatever source IP range your ISP runs scans from? Port will look closed to them, but open to everyone else.

      If, on the other hand, what you want is extra security - well, that's what strong encryption is for. Port knocking is more on the level of ROT13.

    6. Re:Great for warez... by Anonymous Coward · · Score: 2, Interesting

      This is just a technicality, but if you knock on closed ports and shortly thereafter your home system opens a client connection to the ip which knocked, are you running a server?

    7. Re:Great for warez... by Dj · · Score: 3, Interesting

      Well with a little work, you could knock an open sequence, and then knock a sequence which had a port number, and then we open the requested port and start the server app up on that port. Tada! Secret knock port requesting. Now you can pick any port and spread the traffic over different ports over time.

      --
      "You know you want me baby!" - Crow T Robot
    8. Re:Great for warez... by revmoo · · Score: 2, Informative

      Incorrect.

      You connect first to the server, it then queries your machine on 113 to see if you are who you say you are and let you in(or not).

      How is a server supposed to know to ident you if the ftp port isn't open first?

      --
      I would expect such blatant racism on Fark, but on Slashdot? Mods please ban this asshole.
    9. Re:Great for warez... by Ctrl-Z · · Score: 2, Funny

      Time to file a patent.

      --
      www.timcoleman.com is a total waste of your time. Never go there.
    10. Re:Great for warez... by lommer · · Score: 2, Informative

      I think that ISPs could simply then start looking for seemingly random port probes by machine A on machine B, followed by machine B spewing gobs of data to machine A on a random port. That's the trick, make your protocol too good and it'll stand out because it's too random. If you ever actually talk to anyone who works at ISPs though, they generally just flag those customers with unbelievable upload/download ratios and then have a human look at their logs to see if they're violating the TOS (running a server, hosting warez, whatever).

  6. Knock Knock? by qualico · · Score: 4, Informative

    Who's there?

    Just a bunch of hackers knocking with sequences they captured from sniffing.

    1. Re:Knock Knock? by DarkMan · · Score: 5, Insightful

      Meh, throw some cryptography into the mix.

      Take the source IP, add a password, take a one way hash. Include this hash in the knocking packets.

      Now, if you've sniffed the packets, then you won't know the password. So, you can spoof the source IP, in which case the port will be opened _for that IP only_, or you can send the knocking packets from you IP, in which case, you need that password, or you've just advertised yourself as a hacking attempt.

      In order to prevent a single password for everyone situation, it's not hard to include a user ID in the packets.

      Does need the application or firewall to allow connections to and from specific IP's only - but I really can't see that being an issue.

      Problem solved.

    2. Re:Knock Knock? by timeOday · · Score: 4, Informative

      Not unless they can get into a router on the path between you and someone valid who logged in, or the same ethernet segment.

    3. Re:Knock Knock? by brettbender · · Score: 2, Interesting

      This is a replay attack. So don't use a static (replayable) sequence of ports for the knock sequence. Instead, require a dynamic sequence that is a function of the current time.

    4. Re:Knock Knock? by Anonymous Coward · · Score: 4, Informative

      Encrypted port knocking is pointless. Here's why: Port knocking only makes sense if the protected system reacts to the individual knocks as if there was no port knocking system. Only when the knock sequence has been completed it opens the port. This means that you can't do any handshaking. All communication is one-way until it's "too late". Consequentially, since there is no challenge which could require a different response, replay attacks are unavoidable unless you use one-time passwords and then there's no point in encrypting the passwords.

      If you decide to send a challenge to the knocker, you could just as well use regular authentication over a TCP channel.

      The point of port knocking is to hide the existence of a regular channel, not to protect it from someone who knows that it's there. Someone who can sniff your packets is by definition already past that layer of protection, so any attempt to complicate the knock-layer will only increase the chance of creating another vulnerable interface. Keep it simple or don't do it.

    5. Re:Knock Knock? by tonywong · · Score: 5, Interesting

      It gets better than that. Just imagine a honeypot connection for people who don't port knock. That way there is a better measure of security through obscurity since non-port knockers believe that they're actually getting through the systems' defense layers.

  7. Port Knocking Needed by SeinJunkie · · Score: 2, Interesting
    I believe this technology is needed to be pursued greatly. The unwanted traffic that anybody running a website or FTP server sees generated everyday in his server logs is enough to make port knocking a necessity.

    I wonder though. If port knocking is to become popular, will it be able to work through all of the blocked ports resulting from the excessive worm attacks?

    1. Re:Port Knocking Needed by kir · · Score: 4, Informative

      Worms port knocking? That would be one very very very slow moving worm!

      Remember. There are 65535 different ports available. So, given that you can repeat port numbers and one uses a 4 port "combination", you get this.

      65535^4 = 18,445,618,199,572,250,625 different "combinations"

      I'm not even sure how to read that, but I doubt a worm would try it. It might take it a while.

      --
      3cx.org - A truly bad website.
  8. old by ozric99 · · Score: 5, Funny
    When the server detects a specific sequence of port-hits, it runs a command defined in its configuration file. This can be used to open up holes in a firewall for quick access.

    pfft, XP has had this for ages....

  9. ISP Port-Scanning by ckswift · · Score: 5, Insightful

    This might be useful when ISPs routinely port-scan their subscribers to discover if their running services in violation of their TOS.
    This will allow your computer to appear not to be running services expect to the person who knows the magic knock.

    1. Re:ISP Port-Scanning by meme_police · · Score: 2, Informative

      That would be a benefit. Those using port-knocking for extra security are misguided, though.

      --

      The meme police, They live inside of my head

  10. Fyodor must be busy... by stevens · · Score: 5, Insightful

    I'm betting that nmap binary is about to get much bigger...

  11. Port knocking not exactly a new idea.. by morelife · · Score: 3, Funny

    The port knocking idea is pretty old.. at least for months now all kinds of people are knocking my 135 1433 3127 and a bunch of others to DEATH, like hundreds a day, trying to get in..

    Oops, that's Microsoft port knocking.. never mind, sorry, I guess it is new to Unix..

  12. Knock Knock by Anonymous Coward · · Score: 5, Funny

    Who's there?

    Packet.

    Packet who?

    Packet up bitch, you've been hacked.

  13. how long till... by Anonymous Coward · · Score: 5, Interesting

    till we see virus/worms that install port knocked backdoors.

    'virus x appears to open up 200 ports for no real reason, but it also has some remote desktop code in there too opened on a firewalled port....'

    1. Re:how long till... by jg_elliott · · Score: 2, Informative

      I may be wrong, but I was under the impression that all knocked ports were closed and a cron job watched logs, and then opened a port if it noticed the correct knock. This is great for linux, were things are logged, but does windows have a loging facility of this kind? If not, the ports must be open for a program to know if someone has tried to connnect, which defeats the point. With most trojans being on windows, it seems that this isn't a viable feature to add.

    2. Re:how long till... by hank · · Score: 2, Informative

      As I understand it, the ports do not have to be open. You can listen on the link-level and monitor incoming packets even if the port is closed.

      At least, this is how the implementation this article mentions does it (or advertises it does). I've yet to thumb through the code.

    3. Re:how long till... by hank · · Score: 2, Informative

      "This port need not be open -- since knockd listens at the link-layer level, it sees all traffic even if it's destined for a closed port." This is from the page of the implementation this article is about.

      Also, the first sentence from portknocking.org: "Port knocking is a method of establishing a connection to a networked computer that has no open ports." A little further down on the page: "This is a form of IP over closed ports."

      Also, you may wish to read the FAQ: http://www.portknocking.org/view/faq.

    4. Re:how long till... by xsbellx · · Score: 2, Informative

      You are quite correct, ports are not used at the link level, however once the packet is received by the adapter it is processed by a software stack.

      There are several products that implement similar concepts. Take a look at bridging firewalls. Neither interface on the bridge has an IP address but can still inspect packets and take action as required.

      --
      If VISTA is the answer, you didn't understand the question
  14. authpf? by m0rph3us0 · · Score: 4, Interesting

    Why use port knocking. It is no more secure than plain-text passwords. Use authpf. authpf can be set as the shell so when a user logs in authpf just changes the firewall rules.

    1. Re:authpf? by smcavoy · · Score: 5, Insightful

      passwords and port knocking are two different things.
      A perfect example of what it could allow to be done is on knockd's homepage.
      Basically, ssh would not be an open port, you'd have to knock (connect to) the right sequence of ports, which would trigger a rule that could allow only the IP that made the successful knock, access to the ssh port.
      Then when your done you would have another sequence of ports you'd have to "knock" in order to remove the rule allowing access.

    2. Re:authpf? by debrain · · Score: 2, Interesting

      Why use port knocking. It is no more secure than plain-text passwords. Use authpf. authpf can be set as the shell so when a user logs in authpf just changes the firewall rules.

      I'm not sure that authpf corresponds to port-knocking's subject-matter.

      You can make port-knocking more "secure" than encryption; you can use a time-synchronized one-time pad to construct and vary the ports, flags, TCP options, sequence, etc., to come up with a system both unique and impossible to duplicate, absent the one-time pad.

      As one-time pads are provably secure, you can create a system that bars or ignores all communication except the effectively random knock that unlocks the door.

    3. Re:authpf? by Welsh+Dwarf · · Score: 2

      Yes, but if you have to knock to get to the server, and then you have to authentificate (aka through ssh) you have an extra layer.

      --
      Ask 8 slackers a question, get 10 awnsers (a citation, but I can't remember from who)
    4. Re:authpf? by debrain · · Score: 4, Informative

      The usable alphabet for a suicide TCP packet header is, I do believe, in bits:
      16: dest. port
      16: src port
      32: seq id
      6: flags
      16: window
      16: urgent
      40: options
      That gives us an alphabet 2^142 ~= 5.6 * 10^42. Not to mention that a sequence of packets can be combined, extending the language. Indeed, its cardinality is a natural ordinal, so the same as any password, if not more, by virtue of passwords being limited by an input buffer.

      Knocking need only finite state between packets, simply indicating a status of "last packet correct knock?"; successive knocking therein is in a cardinality greater than passwords. Knocking can happen over a period of months (as I have seen it), and be virtually undetectable for all but the most sophisticted (ie. expensive) means of detection.

      In combination with a time-synchronized one-time pad, you can generate an unrepeatable, provably (in the mathematical sense) secure system of access or commands. For example, for the minute of 13:01 EST, there can be a specific TCP packet, or series of packets that unlocks the door or executes a command. At no other predictable time would this knock be useful. (Time synchronization here is an issue, but often this attack will be used on machines that do care about an atomic clock sync).

      You can do the same thing with a password over SSH, but that's higher level, using more complex code, and inherently more likely to succumb to high-level assaults such as buffer overflows, as well as mathematical assaults on the encryption itself, both of which fundamentally compromise the system's security.

      In short, time-synchronized knocking is safer, simpler, and smarter than passwords or encryption for a certain number of niche applications.

  15. knock-knock by after · · Score: 3, Interesting
    That server is about to get more knocks then it can handle, its starting to get pretty slow loading for me.

    knockd is a port-knock server. It listens to all traffic on an ethernet interface, looking for special "knock" sequences of port-hits. A client makes these port-hits by sending a TCP (or UDP) packet to a port on the server. This port need not be open -- since knockd listens at the link-layer level, it sees all traffic even if it's destined for a closed port. When the server detects a specific sequence of port-hits, it runs a command defined in its configuration file. This can be used to open up holes in a firewall for quick access.


    This is an interesting idea, but not very secure. If there was, for example, a need to "knock" a server to activate some sort of access control, then anyone can send the TCP/UPD packets (AFAIK) someone correct me if i'm wrong.

    Looks interesting though, but inetd could do the same thing.
  16. Another implementation by frobisch · · Score: 5, Informative

    is pasmal

  17. Nice start by javatips · · Score: 4, Insightful

    That's a nice start.

    It would be nice to be able to use one-time pad to generate the port sequence. By changing constantly, it would be almost impossible for passive listeners to snif the port sequence.

  18. Re:Multiple kocks by aWalrus · · Score: 3, Informative

    Well, the knocks do come from the same IP, so this thing just needs to be able to see that to filter different knock sequences, I guess.

    --
    Overcaffeinated. Angry geeks.
  19. Interesting by debrain · · Score: 5, Interesting

    This sort of clandestine type of communication has been known about in the security community for a long time - pretty much since the ARPA days. Some backdoors used specific sequences of TCP flags, with no practical TCP use other than opening a backdoor, but permitting anonymous communication or command broadcasting.

    With access to a TCP stack and a link-layer sniffer, you can send and receive, respectively, commands to ghosts in working machines, transparent proxies or "harmony" devices. It is good to see this sort of thing coming to light, since it is extraordinarily powerful and not very well known.

    An example of these probing commands are Xmas, Fin, and Null scans for Fyodor's nmap; note that other TCP flags (TCP options, in particular) can harbour substantially more information than the flags alone.

    Unfortunately, in the modern age of macro viruses, it is hardly necessary to be skilled or even aware of such devices to write a devastatingly powerful virus.

    1. Re:Interesting by evilviper · · Score: 2, Insightful
      it is hardly necessary to be skilled or even aware of such devices to write a devastatingly powerful virus.

      How can you consider this any more secure than a password prompt? It's simple old obsecurity. There are less combinations of TCP/IP flags than there are letter/number combinations, so a flag-based system is easier to brute-force, not harder.

      Once your worm has been decrypted, everyone will know what TCP flags need to be set, and anybody can connect. It's not like you're going to fool anybody here.

      And let's not forget about all the firewalls out there that might decide to drop your packet because of the flags. I know mine will drop any initial packet that doesn't have Syn (and only Syn), so you'd be out of luck.

      Please fill me in, how would this make "a devastatingly powerful virus", or even a reasonably secure authentication method?
      --
      Slashdot gets worse every day... Pipedot: News for nerds, without the corporate slant
  20. Port Knocking implementations by bwhaley · · Score: 4, Informative

    Lots of info available via a google search...

    A few implementations here.

    I don't think will be very useful/valuable until clients (such as ssh) have it built in. I don't feel like going through the hassle each time I want to connect. Though it would keep comcast from discovering my ssh service...

    --
    "I either want less corruption, or more chance
    to participate in it." -- Ashleigh Brilliant
    1. Re:Port Knocking implementations by lambent · · Score: 5, Interesting

      Off the main topic, but regarding comcast ...

      I've spoken with several reps at Comcast over the past year. They don't really care what servers you run. (I've been told this explicitly as well as tacitly) In fact, when I first contacted tech support, the guy had no idea what SSH, Telnet (ssh is like an encrypted telnet, right?) or even what a port was.

      I've been running an ssh server for about 8 months uninterrupted, now. The general rule of thumb seems to be - If you don't cause trouble for anyone else, Comcast won't cause trouble for you. So, in that interest, I impose reasonable caps on my own throughput and connection counts, and I've had no problems at all.

    2. Re:Port Knocking implementations by Krunch · · Score: 2, Interesting

      I think it's not hard to write a simple wrapper around any SSH, FTP,... client. A simple shell script using netcat should do it.

      --
      No GNU has been Hurd during the making of this comment.
  21. About as secure as telnet(1) ie not. by Dr.+Zowie · · Score: 3, Informative

    The problem here is that the ``password'' (the port knock sequence) is sent in plaintext. Anyone with a sniffer anywhere between you and the other machine can see what you're doing. If this ever catches on, any L337 |1dd13 with half a rootkit will be sniffing for anomalous port-requests, and you'll be just as hosed as if you logged on via telnetd.

    1. Re:About as secure as telnet(1) ie not. by eth00 · · Score: 3, Insightful

      Yea but if you have ssh open with this it is just another layer of security. It is hard to truly secure a box with no openings and this is just one more thing that will trip people up. If you implement this and somebody tries to brute force your password or something it would certainly take longer (if they are not locked out because so many tries first). In todays world it is just one more tool that can be added to the computer security arsenal. Hell it would not even be a bad back door to your own box. Imagine a remote box and you upgrade ssh...but it fails. You simply portknock and have some odd port with telnet open up. You just saved yourself some money and time of having somebody go and fix the server from the console.

    2. Re:About as secure as telnet(1) ie not. by LordKronos · · Score: 4, Interesting

      Exactly, this whole idea is stupid. It's a password sent one character per packet instead of all in the same packet.

      As I said the last time this idea appeared on slashdot, if you want to hide a port from someone but make is still accessible to people who know the "password", here is what you do.

      1) stealth the port by default, so it accepts no TCP connections.
      2) Have the port silently listen for UDP packets. UDP is fine, because no acknowledgement is sent to the sender, so they don't whether you recieved the packet and ignored it, or if it never got to you.
      3)When you receive a UDP packet, see if it contains the correct password. If it does, than you start accepting TCP connections for that IP address only.

      At this level, this is just as secure as port knocking (password=port sequence). However, it has an advantage that port knocking doesn't. You can encrypt the packet with the server's public key, so that only the server can get the password out of the packet. You can also require that the packet contain an IP address in addition to the password and then verify that the IP in the packet matches the IP the packet came from. This prevents people from intercepting and replaying the encrypted UDP packet.

  22. Why is this more secure... by TheSHAD0W · · Score: 4, Insightful

    Than a single coded UDP packet?

    1. Re:Why is this more secure... by Creepy+Crawler · · Score: 2, Informative

      Because UDP is usually bandwidth filtered as it's the easiest protocol to flood a connection.

      Ethernet has a exponential-wait scheme to prevent cloging of pipes, and TCP uses a authorized sent only packet. No data is send until prior ones are OK'ed.

      --
    2. Re:Why is this more secure... by CyberVenom · · Score: 3, Insightful

      In that case, you could accomplish the same thing with a single ICMP packet that has in its payload a port number to open, followed by a hash built from the port number, current epoch time (as synchronized from the USNO clock), the password and the destination IP (to prevent the same packet from being replayed within 1 second against another server that has the same password). Viola! You now have a time-dependant, unilateral unlock mechanism piggybacked on an existing, allowed protocol, whose reply packets can easily be dropped in every case but a successful auth, making the server invisible to ping sweeps. The time sync window can be as small as a few seconds if both machines synchronize their clocks from the USNO. Obviously once a particular hash is used, the server should reject any further uses of that hash within 1 second to avoid instant replay attacks.
      A similar procedure could also be used to dynamically route ports (sort of like portmap) through a NAT firewall to specific hosts on the inside, thus moving the software requirement off of the server itself and onto the firewall. The client side can be just a small userland app to unlock the port, then the normal program can initiate the port connection (ssh, eMule, kMail, or whatever)

  23. portknocking.org by trip23 · · Score: 5, Informative

    You'll find some more stuff on http://www.portknocking.org...

  24. Time based defenses by frenztech · · Score: 5, Interesting

    I remember talking about port knocking and its inherent sniffing vulnerability previously.

    Basically, if someone can sniff the sequence of packets, they can get your static knock sequence.

    However, if you base it on their IP perhaps, or add in a timestamp (ie, on this date, at this time, you must do this sequence) then it would make port knocking a much more effective method of deceiving attackers.

    You could also do something where knock sequence would be a form of one time password. So you would have a list of valid knocks that could only be used in order. Each person could be given a "block" of these one time passes, or the sequences could be generated on the fly as other current implementations of one time keys are.

    There are lots of great possibilities, if only I were smart enough to think of them ;) I'm currently implementing a c++ networking class for a project with port-knocking built in, and it uses the timestamp method. (Of course, they all have to compute the timestamp for one zone, GMT or wherever)

    --
    "Sed Quis Custodiet Ipsos Custodes?" -Juvenal
    1. Re:Time based defenses by frenztech · · Score: 2, Interesting

      Refer to my original post.

      You are correct that if you have a static knock sequence, that's not that good. However, if you have ever-changing sequences that combines time windows with other external factors, then unless you knew the sequence beforehand (since it changes everytime), you would have no way to guess what it was besides running a brute force attack, which is outside the scope of this sort of defense, since it brings into account lots of other issues liked using spoofed packets to DOS IDS/IPS etc.

      --
      "Sed Quis Custodiet Ipsos Custodes?" -Juvenal
  25. Sniffing only works when on that network. by khasim · · Score: 4, Insightful

    You can only sniff packets on a network you are attached to.

    What that means in real life is that someone would have to be connected somewhere along the route from your machine to the server you're knocking on.

    I am in Seattle, I can knock on my server from another location in Seattle. Someone in Canada will not be able to capture any of my packets.

    Port knocking allows me to run a service on the Internet and not worry about just anyone from anywhere connecting to it.

    1. Re:Sniffing only works when on that network. by Anonymous Coward · · Score: 2, Funny

      Unless, of course, they've already installed a backdoor on your neighbor's unpatched windows box and are watching cable modem traffic on your subnet

      Or "they" might have drugged your coffee, stole your keys, broke into your house, installed cameras everywhere, put a tap on your phone line, installed key loggers on your computer, ....

    2. Re:Sniffing only works when on that network. by MerlynEmrys67 · · Score: 3, Informative
      I remember when:

      Seems my office was 2 miles down the road from my house - traceroute from my house in Portland, OR to my office went through both Seattle AND MAE-West (Bay Area, CA)

      Many external countries only have external connections to the USA, not directly to each other (don't know how true this currently is - but several asian countries used to have to hit the W Coast, USA to get between each other)

      --
      I have mod points and I am not afraid to use them
  26. Security by David+Hume · · Score: 2, Insightful

    This is an interesting idea, but not very secure. If there was, for example, a need to "knock" a server to activate some sort of access control, then anyone can send the TCP/UPD packets (AFAIK) someone correct me if i'm wrong.


    If I understand it correctly, this could be very secure. Imagine trying to guess the combination of a combination lock where each port number represents a possible number of the combination, and the combination is of unknown length (e.g., a combination 3, 5, 45, or 105 numerals long, etc.). Moreover, it might be possible to have the system bar further attempts from a given IP address after two or three failed attempts during a given period of time.

  27. So how do you 'start' this? by purduephotog · · Score: 3, Funny

    Do you type:

    >/etc/rc.d/rc3.d/s95Knock UP

    ?

  28. So there I was by ch-chuck · · Score: 4, Funny

    I'd just scp'd a new file to my ISP, ssh'd in to edit index.html, checked email, and then when I refreshed the page in http, suddenly I has root access!

    --
    try { do() || do_not(); } catch (JediException err) { yoda(err); }
  29. Re:Knock Knock by Dorothy+86 · · Score: 2, Funny

    I knock, knock, knocked on that Gibson's door!

  30. Re:Multiple kocks by JPriest · · Score: 3, Informative

    The nimrod that modded this as insightful need to go back and read TCP/IP for dummies. They knock from different IP addresses, and even in situations where 2 hosts are knocking from the same IP (behind NAT) you still have a different source port.

    --
    Saying Java is nice because it works on all OS's is like saying that anal sex is nice because it works on all genders.
  31. Sorry Wrong URL by image53 · · Score: 2, Informative

    Can you tell I don't post to blogs much? Port Knocking

  32. It's broken, and the real solution is simple by Anonymous Coward · · Score: 5, Insightful

    Sniffing the sequence allows a replay attack.

    The correct implementation is to listen in promiscuous mode for any packet containing a small, known header, then inspect the rest of the packet for a gpg-signed request to open a port or service, or alternately initiate a connection. Only the possessor of the private key can make a request (attacker's attempts fail the signature check), a man in the middle cannot decrypt the contents, and replay attacks are defeated by the timestamp.

    -1, Security by Obscurity.

    1. Re:It's broken, and the real solution is simple by Torne · · Score: 4, Insightful

      If you use signatures, IPSEC, or anything more complex than knocking, you need the client to support it. You can knock using nothing but telnet. That's kinda the point. =)

  33. It's all about layers of security by pkiguruman · · Score: 4, Insightful

    If you are using portknocking as your only defense, then you are as smart as dirt and deserve what's coming to you.

    I think it fits in great as a layer of defense.
    Is there an easier way to weed out the attempts from all of those script kiddies and worms to get into certain services on your network?

  34. Implementation which is sniff resistant by 3Volker · · Score: 2, Informative

    www.portknocking.org

    Note the encryption/hash of the ports, source IP, and port to be opened.

    www.portknocking.org/view/documentation
    There is a Perl reference implementation. (GPL'd, of course)

    "I am in no way affiliated with this group."

  35. Re:Secrets are not security by Gaijin42 · · Score: 3, Insightful

    Well, then there is no such thing as security.

    Your 10000000 bit PKI key is just a secret. If you are relying on not giving that secret out to handle your security, then you don't have any. Its just a secret, I guess I am better off not using encryption

    The arrangement of pins in my doorknob is a secret. I guess I am better off not locking my doors.

    The password to log into my workstation is just a secret. I should just leave it open.

    The more "secrets" you have in any given situation, the better secured you are.

    Random portscans where they get all your secrets wrong : could be random noise.

    Random portscans where they get 2/3 of your secrets right : You have probably identified an active intrusion attempt. Also you have identified a possible leak in your secrets. Time to change the passwords.

  36. Responses to assertions that this is insecure by cryptor3 · · Score: 5, Insightful

    A number of people have commented that because the port knocking sequence is transmitted without any form of encryption, port knocking is insecure. I disagree, on the basis that port knocking is not an access control measure, but rather a deterrent measure.

    If you intend for port knocking to stop determined, targeted attacks, then yes, you are sadly mistaken. However, port knocking is effective in making your host less attractive to be hacked.

    I think that an limited analogy is the removable stereo faceplate. Car stereos are a hot target for car thieves. A car thief sweeping a parking lot will not spend time on cars where he does not see the whole stereo (faceplate included).

    By hiding the faceplate, you make yourself less likely to be a victim, even if you just leave the faceplate in your glovebox. If the thief saw where you hid your faceplate, then yes, he could pop it back in and have your stereo in the 30 seconds it takes him to yank it out. But he would have to be watching you. This would be akin to packet sniffing.

    Likewise, someone scanning for a host is looking for evidence of a particular (vulnerable) service. If he doesn't see that service on your PC, he just moves along.

  37. Re:Secrets are not security by Sique · · Score: 3, Insightful

    It looks as if you don't grasp the concept here. No one requires the knocking sequence to be static. Only the knockd as a proof-of-concept implementation uses a static sequence to keep the program simple and point out what Knocking adds to the normal server concepts. Authentifying yourself against a server with a nonstatic sequence is not a new concept in this context, so it was not focussed on during knockd's implementation.

    No one will stop you to implement an adv_knockd which requires the knocking sequence to be the current time in GMT, signed with your private key. Then your adv_knockd checks your signature with your public key and verifies the timestamp.

    This makes your adv_knockd invulnerable against replay attacks, if you declare an sequence already sent to be invalid for the next hour (you have to allow for a grace period in the timestamp, because of network delays and asynchronous clocks, so a replay of an already sent sequence within a few seconds would still come through).

    The knockd is explicitly called a proof-of-concept. Using it directly as part of your security policy is strongly disencouraged :)

    --
    .sig: Sique *sigh*
  38. Re:Secrets are not security by Mr2cents · · Score: 2, Funny

    Secrets are not security. Give me your pin code.

    --
    "It's too bad that stupidity isn't painful." - Anton LaVey
  39. A different solution by Pros_n_Cons · · Score: 4, Informative

    there is another similar idea written by Brian Hatch author of Hacking Linux Exposed. Instead of 'knocking' ports which as I understand it can be vulnerable to brute force like attacks Hatch's solution uses dns queries to dynamicly open up ports through the firewall, using the dns query as a password. There is no 'service' listening but there is a sniffer waiting for a key string on port 53 that it will take action on. The best thing is it is OS agnostic since DNS query tools are already on all OS's no client software, or technical know-how is needed. And easily customizable if you're fluent in perl.
    These kind of things are not ment for full access, only by allowing you access to the daemon which still has its own acl. When you travel sometimes you're not aware of what IP address your laptop will have so you set a dns query to your home machine which opens the SSH port for you. The whole point is to prevent random attacks from people scanning vulnerable daemons. The following are links to Brian Hatches explinations and code.

    Part 1
    Part 2
    Part 2

    --

    -- "of course thats just my opinion, I could be wrong." --Dennis Miller
  40. port knocking with perl by ubiquitin · · Score: 4, Informative

    My friend Thom Harrison at the Omaha Linux Users Group has posted some scripts which do port knocking and have the following CPAN dependencies:

    |use File::Tail;
    |use Crypt::CBC;
    |use Schedule::At;
    |use Math::VecStat qw(sum);
    |use POSIX qw(strftime);
    |use Pod::Usage;

    --
    http://tinyurl.com/4ny52
  41. Used to be done in phone systems by HPNpilot · · Score: 5, Interesting

    Well at least I used to build them in. It was so simple many others must have done the same thing. Take a 10-step relay, put a 1 minute reset timer on it, and wire each of the first few steps to a pulse gen anded with one of the incoming lines' ring detect. If the right sequence of incoming calls happened, it connected a separate incoming WATS line to a WATS outgoing line. Viola! Free calls from anywhere to anywhere, and nobody would ever notice if you were careful to only select "unlimited" outgoing WATS lines. We're talking something like 35 years ago here...

    1. Re:Used to be done in phone systems by Alioth · · Score: 2, Interesting

      You might be interested in this website: Light Straw. I particularly enjoyed the stories of the old manual international exchange where operators would put calls through by hand during the 1970s or thereabouts. Looking at all that kit, it's no wonder phone calls used to be so expensive.

      I work with a former phone engineer who told me about a night in the exchange - the place was very quiet, and then at 8.00pm, all the switches started going, building into a massive crechendo of sound, the entire exchange turning into a deafening cacaphony of selectors...well, selecting. He said it was spooky. He shortly afterwards discovered the event that prompted all this activity was the dramatic end of an episode of a primetime TV soap.

      One of the things that surprised me was all the tones were generated by essentially a big electric motor driven thing (I think Light Straw has some samples of the tones along with an engineer testing the thing). I'm just old enough to remember the last Strowger exchanges (our local exchange went digital in 1989 IIRC) and I sort of regret not badgering a BT engineer into letting me in the building and watch this thing go. Perhaps I'm just a bit too geeky, but I love electromechanical stuff.

      Digital phone exchanges seem so...dead...by comparison.

      The Grumman Cheetah is a neat plane, the Association of Manx Pilots have one which I've got a few hours in. Probably the best nosedragger single in my budget :-) I used to have a half share in an ancient Cessna 140 (see http://www.dylansmith.net) which I flew coast to coast across the US. It's a big place at 85 knots!

  42. Use of port knocking... by frenztech · · Score: 2, Insightful

    The use of port knocking should be as a deception device, not necessarily as an active defense.

    You are hiding the fact that you have something to hide, ala steganography. Once that something is found (the knock sequence), it is open to attack just like anything else.

    Stego + encryption is the way to go. Not necessarily for this application (port knocking), but it could have some great security uses.

    So with port knocking, you still want that encrypted channel to be required (SSH, etc.) on the port that you successfully knock to.

    --
    "Sed Quis Custodiet Ipsos Custodes?" -Juvenal
  43. More secure than people think by Experiment+626 · · Score: 5, Interesting

    Most of the arguments here against port knocking are along the lines of "but someone could just do a replay attack" or "this is vulnerable to spoofing" or whatever. These things are true about a naive implmentation of port knocking that uses a static knock, but it's not hard to come up with variants on the port knocking idea that offer much better security than that. For instance:

    1. Connect to server on some constant, always-open port.
    2. Server sends back a string, then closes connection.
    3. Using this string and a secret password, determine the current knock sequence.
    4. Connect to server using this knock sequence.
    5. Once a knock sequence has been used, serevr invalidates it, creates a new sequence, and begins publishing the string corresponding to the new knock sequence.

    The secret key of course has to be kept secret, and the underlying crypto must be good enough that if the attacker sees the challenge and the knock sequence used to reply, the key itself cannot be deduced.

    This would completely protect from replay attacks, as knocks are not reused. Spoofing could potentially be used to DOS someone by interfering with their knock sequence, but not to gain unauthorized access oneself.

    Sure, at first glance port knocking may seem to be of limited usefulness, but if you combine the idea with a little cryptographic thinking, the possibilities start to become a lot more exciting.

  44. Services by PsimanX1 · · Score: 2, Insightful

    One of the cool things with this is that you could set it so that it actually starts SSH or the FTP daemon or whatever as well as open up the firewall on the appropriate port and shut it down again after.

    Saves mem usage as well as being that teensy bit more secure!

    Also in answer to post further up - WinXP's firewall can log dropped packets to a text file.

  45. i've noticed a lot of posts by timmarhy · · Score: 3, Insightful

    bagging secret methods of keeping things secure. well i'm sorry kids but ultimately keeping something secret is necassary for a secure system. what is NOT secure is keeping that secret in an accessable mode. good passwords are the most effective way of having a secret way into a system, since your brain isn't plugged into a computer it's only accessable to the correct person. port knocking sounds intresting, but it's like having a secret knock to let you in a physical door, anyone listening will know that secret knock.

    --
    If you mod me down, I will become more powerful than you can imagine....
  46. try doorman.sourceforge.net by F.Z.Bunny · · Score: 3, Informative

    For portknocking, try doorman.sourceforge.net Got crypto.

    --
    --- There is no bun but Bun, and Fuzzy is His prophet! Bunbun akbar! ---
  47. Even better for IPS? by quarkscat · · Score: 2, Insightful

    Actually, as the CPU clock speeds up, port-
    knocking may prove to be an ideal way to keep
    the black-hats out of your network. Imagine
    applications that don't maintain explicit
    open ports, but only open up a port with the
    right "shave-and-a-haircut" knock-knock. If
    generic port scans can't find any holes, how
    do the script-kiddies break in?

  48. Anti-Server Broadband Monopolies by billstewart · · Score: 3, Interesting
    It's really annoying when cable modem companies do this, because there's almost always at most one cable tv company in a given area, so if they're clue-deficient, you don't have an alternative. (And most of them are not only clue-deficient, but contagiously clue-hostile.)

    It's much less of a problem when DSL providers have policies like this, at least in the US, because usually the ex-monopoly telcos rent their copper to multiple DSL Layer 2 providers (often including themselves), and the DSL providers usually provide connectivity to many ISPs. So even if, for example, SBC DSL ISP service has some stupid policy, SBC provides Layer 2 access to many ISPs including Sonic.net and Speakeasy, who have friendly clueful policies, and they rent copper to Covad, who provide Layer 2 access to many more ISPs (sometimes with fewer connectivity options, e.g. maybe only SDSL or IDSL and not line-shared ADSL.) Sometimes these alternatives cost more - I'm paying about US$57/month for Sonic.net ADSL with four static IP addresses, vs. some of the newer loss-leader $29 deals from other providers.

    Most other countries don't seem to have policies against being a Real User on your broadband service, at least if you're not commercially reselling it. Theoretically, this means that all those non-Americans out there should be creating lots of cool and interesting things to do with their broadband services, but I haven't seen much other than Yet Another File-Sharing System variants or some of the Asian grocery-shopping-on-line things that get magazine articles written about them but aren't very useful outside their local areas.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  49. Authpf *IS* another layer by billstewart · · Score: 2, Insightful
    If I'm reading the Authpf FAQ correctly, Authpf is a service that you run on your firewall, not on the target server behind it. Logging in to authpf on the firewall is equivalent to knocking on the firewall - both of them tell the firewall to let you access the target server that's hidden behind the firewall, and if you don't knock/authpf, the firewall won't let you in.

    There are some tradeoffs - knocking systems are usually lightweight, while authpf is probably more thorough, especially about making sure the firewall hole gets closed when you leave. Different knocking systems have different bugs in them, and OpenBSD+SSH+AuthPF has the risks of more people attacking it, but the knocking systems have random authors while Authpf and its environment have to be blessed by Theo, so you've got some level of assurance about QA and future fixes. Also, knocking systems need various clients to knock with, and may be susceptible to firewall damage in between, while SSH is pretty widespread and firewalls generally let you make outgoing SSH connections.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  50. Order and Delivery Of Packets Is Not Guaranteed! by Dr.+Manhattan · · Score: 4, Informative
    Packets are not guaranteed to arrive in the order that they were sent, or even to arrive at all. The longer or more complex the knock sequence, the more unreliable this system will be. Especially for a busy server.

    There are less stealthy but more secure alternatives. I wrote one.

    --
    PHEM - party like it's 1997-2003!
  51. Parent is wrong by Ernesto+Alvarez · · Score: 5, Informative

    Encrypted port knocking is pointless. Here's why: Port knocking only makes sense if the protected system reacts to the individual knocks as if there was no port knocking system. Only when the knock sequence has been completed it opens the port. This means that you can't do any handshaking. All communication is one-way until it's "too late".


    The idea in the grandparent post wasn't a challenge-response in the traditional way. It was some authentication data along with the knocking.
    The knock won't be encrypted, but it will have some data that is characteristic of the source (the source IP) that can't be spoofed (because of the password and the one way hash).

    An example of this would be:

    1.Real owner takes his IP (public info)
    2.Real owner takes his secret password (known only to him)
    3.Using IP and password he computes the hash and sends it in the knocking packets (let's say it's in the IP id)
    4.The receiving system captures the knocking packets and takes IP source and the hash
    5.It reads the secret password (from config file)
    6.It calculates the hash with the source IP and password

    If the hash sent and the hash calculated match, the system "accepts" that part of the port knocking. If not, discards the packet.

    An intruder might only spoof the whole packet (including IP source) and might open the firewall only for that IP. If he tries to use the hash to open it for HIS ip, the calculated hash won't match the hash sent. He cannot calculate the hash he would need because he does not know the password, and the hash is one way.

    In this protocol the target system does not need to respond with a challenge, it just discards packets that are "spoofed" (that have a non matching hash).
  52. Re:Knock Knock? - How to secure IMHO. by ksp · · Score: 2, Interesting

    I haven't looked at the way this is implemented (in true Slashdot fashion), but here's what I would do:

    From client:
    Send a random number, say [1-10] of port knocks, toward random ports.
    Send the true port knock sequence, this has to complete before a certain time has elapsed.
    Send a random number of port knocks again.
    Wait a second or two, then connect to the real port.

    Now, the server side waits for the first correct port and hence ignores you random garbage. Once your first port comes through it waits for a short duration (3 sec?) for the second port knock. If that comes across OK it waits for the next etc.

    A wrong port from the same IP or a timeout causes the entire knock attempt to fail and get logged.

    Once the correct sequence is sent, there is a random delay of a few seconds before the real port (e.g. SSH) is opened so sniffers can't tell exactly when the sequence started and ended within the total port knocks sent.

    Now you are logged in, and since you are connected via some form of encryption (again, SSH or whatever) you are free to change the port knock sequence. Perhaps even done automatically every successful login, with a logged failback to previous sequence if you get out of sync.

    Unless you log in to the opened port within 30 secs it closes and you have to wait 90 secs to send the sequence again.

    You could additionally add individual sequences for static IPs (or even DynDNS?) or even certain individual logins allowed to authenticate after that sequence was received. I expect netfilter modules to be written to handle all of this.

    By the way, anyone who thinks an open SSH port is *safer* than port knocking + SSH is an idiot in my opinion. The first discussions here were full of such comments, they seem to have died off as people decided to RTFA?
    Still, port knocking is not the best option for frequent connects by many users, and can be DOS'ed with IP spoofing or some kind of packet injection.

    --
    What is the sound of one hand clapping?
    cat /dev/null > /dev/audio
  53. Security vs Obscurity by surstrmming · · Score: 2, Funny
    Most of you seem to miss the point. You do not get security through obscurity, but that does not mean obscurity isn't valuable in addition to security. It is.

    Compare this to real life. You have a stack of porn magazines locked in a drawer. The security is the lock, preventing your mother from ever getting access to the porn. That's fine. But surely you would feel much better if your mother didn't even know there was porn in the drawer! That's obscurity. It doesn't make the lock any more secure, but it is useful.