this post was submitted on 24 Aug 2024
17 points (81.5% liked)

Programming

17305 readers
253 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

I've read an article which describes how to simulate the close ports as open in Linux by eBPF. That is, an outside port scanner, malicious actor, will get tricked to observe that some ports, or all of them, are open, whereas in reality they'll be closed.

How could this be useful for the owner of a server? Wouldn't it be better to pretend otherwise: open port -> closed?

top 32 comments
sorted by: hot top controversial new old
[–] originalucifer@moist.catsweat.com 16 points 2 months ago (2 children)

pseudo honeypot ip blocker. you could auto drop traffic from people sniffin where/when they should not be

[–] nous@programming.dev 6 points 2 months ago (1 children)

Would it even need to pretend it is open? If it can fake a port being open then it can tell when a close port is being pinged. So can outright block connections from those IPs without ever pretending it is open?

[–] originalucifer@moist.catsweat.com 2 points 2 months ago (1 children)

sure, if you want to be that black and white about it.. but with this you maybe could glean more information about the attempt and have more granular logic.

[–] nous@programming.dev 1 points 2 months ago* (last edited 2 months ago) (2 children)

What extra information could you gather? Note I assume we are talking about a fake open port here, not an active service listening on a port that can communicate with the attacker. That could be done without eBPF though - so what advantage would eBPF have here?

And I assume this is more on the level of responding to pings than creating full connections? At which point you are only dealing with a single packet from the sender. So what value does responding give you here?

[–] originalucifer@moist.catsweat.com 1 points 2 months ago (1 children)
[–] nous@programming.dev 3 points 2 months ago (1 children)

Port knocking does not require open ports though? It works by trying to connect to closed ports in a specific sequence does it not?

[–] originalucifer@moist.catsweat.com 1 points 2 months ago (1 children)
[–] nous@programming.dev 3 points 2 months ago

What is a fake port?

[–] dnick@sh.itjust.works 1 points 2 months ago (1 children)

At a guess, you might tell the difference between some benign scan and an attempt to actually take advantage of the port, perhaps to use as a trigger to automatically ban an ip address? or a way to divert malicious resources to an easy looking target so they are less available in other areas?

The difference between someone scanning for open ports and someone attacking a port they find open seems significant enough to at least track and watch for patterns... Whether that's useful for the majority of users or not is rarely why a feature is implemented.

[–] nous@programming.dev 1 points 2 months ago (1 children)

What is a benign scan? Why do you need to scan a system if you are not trying to figure out what it is running - which is something only attackers or the server admins (looking for things that should not be exposed) would want to do. Any third party scanning for open ports I would consider an attack. Though it might just be an automated system looking for weaknesses - it is still an attack.

[–] dnick@sh.itjust.works 1 points 2 months ago (1 children)

A benign scan could just be looking for an ftp server to connect to or a repeater or relay server of some sort. There are plenty of open services people make available for free and the fact that you would consider it an attack it doesn't make it one.

At minimum you could be alerted to look for someone attempting to connect to your ftp server with a single basic anonymous authentication vs someone flooding that port with known malicious software attacks, and block the latter across your entire network and effectively ignore the former. Really it seems like you're advertising your lack of imagination in this context than a legitimate lack of possible uses for spoofing open ports.

[–] nous@programming.dev 1 points 2 months ago

Those are not port scans though. A port scan is when someone is systematically checking a large number of ports on a system to find which ones are open and possibly what is running on them. A random connection to a single port is not a port scan and not something pretending that other ports are open will help at all with. And open services are typically announced in some other way and don't require scanning all ports on the whole internet to find. Though you may get connections from people that get the address wrong, or have an old IP that has been reused or something - those are not scans though.

Really it seems like you’re advertising your lack of imagination in this context than a legitimate lack of possible uses for spoofing open ports.

I never said that. I have mentioned actual use cases for wanted this in other comments in this thread - namely slowing down attackers by making them do more work by not being able to do quick checks for open ports. My responses here though are about the postulation that you could gain extra information with an open port in eBPF vs just a closed one or simply a service running on that port. Thus I do not think that is the reason you would want this. Never said there are no reasons at all that you would want to pretend ports are open.

[–] Ephera@lemmy.ml 4 points 2 months ago

Presumably, OP doesn't know the concept of a honeypot, so: https://en.wikipedia.org/wiki/Honeypot_(computing)

Basically, it's a decoy system, which an attacker will likely target.

[–] chameleon@fedia.io 2 points 2 months ago (1 children)

You can't pretend an open port is closed, because an open port is really just a service that's listening. You can't pretend-close it and still have that service work. The only thing you can do is firewalling off the entire service, but presumably, any competent distro will firewall off all services by default and any service listening publicly is doing so for a good reason.

I guess it comes down to whether they feel like it's worth obfuscating port scan data. If you deploy that across all of your network then you make things just a little bit more annoying for attackers. It's a tiny bit of obfuscation that doesn't really matter, but I guess plenty of security teams need every win they can get, as management is always demanding that you do more even after you've done everything that's actually useful.

[–] sapporo@sopuli.xyz 1 points 2 months ago* (last edited 2 months ago) (1 children)

You can’t pretend-close it and still have that service work.

indeed, a service on a port would no longer properly work. However, pretending that an open port is closed is possible the same way when pretending that's open

[–] dnick@sh.itjust.works 1 points 2 months ago

Maybe what you're referring to is along the lines of a port being open but the software on the other side of it not sending acknowledging responses?

[–] litchralee@sh.itjust.works 2 points 2 months ago (1 children)

Can you please kindly link to that article, if it's publicly available?

[–] atzanteol@sh.itjust.works 1 points 2 months ago (1 children)

Possibly to confuse os detection. Not sure if it would be sufficient though.

[–] mvirts@lemmy.world 1 points 2 months ago

Or slow down a complete scan, it would take a long time to scan all likely ports on a machine stealthily, and be quite obvious if that machine is set up as a honeypot.

[–] urquell@lemm.ee 0 points 2 months ago (1 children)

Maybe a port that is actually open doesn't look as interesting

[–] sapporo@sopuli.xyz 1 points 2 months ago (1 children)
[–] nous@programming.dev 4 points 2 months ago (1 children)

From an attacker perspective you would do a quick scan to find open ports, then focus on those ports with more expensive/slower scans to find out what is running on those ports. If everything reports open then what ports do you focus on first? So not so much that actually open ports are less interesting, but that actually open ports are harder to find among all the ports.

[–] sapporo@sopuli.xyz -1 points 2 months ago* (last edited 2 months ago) (1 children)

Do you youself understand what you're talking about?

then focus on those ports with more expensive/slower scans to find out what is running on those ports.

What do you mean by "focus on those ports"? What are "more expensive/slower scans"?

If everything reports open

not every port gets reported to be open but only some of them

what ports do you focus on first?

me? or an attacker? he could work with any ports he wishes

[–] nous@programming.dev 2 points 2 months ago* (last edited 2 months ago) (1 children)

Do you youself understand what you’re talking about?

I am by no means an expert in this area. But I have some understanding of how things work.

What do you mean by “focus on those ports”? What are “more expensive/slower scans”?

There are many different levels of scans you can do on ports - the first and simplest is just trying to connect to see if the port is open. But that only tells you if the port is open. You then need to try and figure out what service is running on the port which is done by trying to communicating with it and seeing what it replys with. E.g. sending a http request to see if a http server is listing, or trying to start a tls connection for https). Once you know what service is running you can make additional queries to try and figureout what version it is running which can tell you what vulnerabilities it is exposed to. Each of these might need a different connection, and you might need to cycle through many different queries to get a response from the server - all of that is far more expensive than just checking to see if the port is open.

So you generally want to preform a quick scan of open ports, then follow up on a deeper scan of those ports to gather more information about what is running on the port. Nmap, the tool generally used for this, has these different modes you can tell it to scan in and is able to do simple TCP connection scans, or more detail scans for detecting the service an OS (and their versions) as well.

not every port gets reported to be open but only some of them

That was a hypothetical, not having read whatever article you are talking about. But I would assume that a eBPF tool that fakes open ports would do so to pretend a large number of ports are open at least. Though that is just speculation on my part.

me? or an attacker? he could work with any ports he wishes

That is from an attackers perspective.

[–] sapporo@sopuli.xyz 1 points 2 months ago* (last edited 2 months ago) (1 children)

Ok, back to this then:

If everything reports open then what ports do you focus on first?

I don't see an issue here. An attacker would be overwhemed with choise and excitement so that he wouldn't be able to decide which port to choose first, get stuck for a several months unable to decide? He'd toss a coin then.

[–] nous@programming.dev 1 points 2 months ago (1 children)

Its costs him time - which is the point. They would have to do more detailed checks on every port which costs them time. Attackers are typically scanning loads of ports over large ranges of IPs, any small slow down on each can drastically slow down their overall progress making the attack less feasible and more expensive to undertake.

[–] sapporo@sopuli.xyz 1 points 2 months ago (2 children)

but an attacker isn't obliged to take on all the open ports, he could work with some of them - the ones that may seem the most interesting to him

[–] dnick@sh.itjust.works 2 points 2 months ago

That's probably a majority of the point. Falsely report that some interesting ports are open and he'll spend time on them and potentially trigger alerts or blocks.

Fake open ports aren't something a normal user would bother with or understand, but with all the tools available in the nefarious side, it makes sense to have options that make their job harder if you're willing to use them.

[–] nous@programming.dev 1 points 2 months ago

Yes, which limits the amount of ports they can search and thus can be used to hide things on less popular ports. It is not going to stop an attacker. Just makes their job a bit harder or less complete.