Readit News logoReadit News
ChuckMcM · 3 years ago
So funny story, for a while I worked on a 'reverse' exploit. Which is to say morphing the response from ssh to the client with large malformed packets. The idea was to crash the client making the request. In my case I found these attacks would have like 6 to 10 attempts from the same source address. By time stamping the requests, I could evaluate if the next attack from the same address came more quickly or more slowly. I then had my server "morph" the return payload somewhat randomly and keep the three responses that caused the most slowdown. When I got to 100 variants that had "won" this selection criteria I took the three best and started over from there. After a couple of months of this I finally got a response where after one request I would not get a second.

I felt extremely pleased with myself for about another month, and then my server address got hit with a massive DDOS attack (for me anyway) over my 6MBPS DSL line. So clearly I had hit a nerve somewhere :-). Anyway, I moved my server to a different address and used fail2ban to just note source IPs and put them into the IP tables as banned addresses. That works great and hasn't resulted in the same sort of drama as last time.

lgats · 3 years ago
Another fun one is sending a redirect to a gzip bomb or extremely large file (i.e. speedtest download file) for when certain non-existant URLs are requested, i.e. /wp-login.php on a non-wordpress site.
KomoD · 3 years ago
Earlier this month I was downloading top 1 million websites' robots.txt and some guy just served 100mb of whitespace :/
gitgud · 3 years ago
Is it legal to host a gzip bomb? Seems like a malicious file to serve up…
Jenda_ · 3 years ago
MySQL has a weird feature, by default enabled in many clients, that the server can request a file from the client.

I have requested /etc/shadow, cracked the hash for root password, and ssh'd back into the botnet node that was bruteforcing passwords. I then shared the information with the webhoster where the botnet was running and a local infamous antivirus company (Avast before it was leaked that they are evil) and got a t-shirt.

https://www.abclinuxu.cz/blog/jenda/2019/2/exploiting-mysql-...

mdaniel · 3 years ago
Outstanding job! My opinion of mysql continues to improve :-/

As a curiosity, I found the submission link in the comments on that thread https://news.ycombinator.com/item?id=19305823

DougMerritt · 3 years ago
Nice. Also an illustration that its good to establish one's inner motive first, like here might range from a desire for simple solutions, to another dimension of drama, which might indeed be desirable sometimes, for entertainment or for snapshots to use in a book one is writing. :)
api · 3 years ago
Try negotiating ssh compression and then sending terabytes of compressed zeroes. Might work for a badly implemented scanner.
KomoD · 3 years ago
Semi-related, I've just started serving large files to webserver scanners, some are so poorly made that they just download the entire file
mike_hock · 3 years ago
You still got the response packets?
sneak · 3 years ago
Disable password authentication and fail2ban becomes completely unnecessary.
wkat4242 · 3 years ago
Not really. A lot of these bots are super duper dumb and continue slamming your server with handshake attempts even if password auth isn't even turned on. Every handshake is wasted CPU resources (and asymmetric crypto isn't cheap). It also makes it harder to see real dangers in the logs.
nico · 3 years ago
You still get the attacks and they show in the logs

Also, it’s not just ssh, there are brute force attacks for pretty much any service that you run

Our logs show automated attempts to run exploits on our web servers everyday

BrandoElFollito · 3 years ago
This. I really do not understand why people use fail2ban when the threat is somewhere else.

It won't stop a ddos but will certainly, at some point, prevent you from logging in.

XorNot · 3 years ago
I prefer libshield but one thing I've found is that annoyingly sshd didn't use PAM to check if the login user is valid apparently (so it never fires when only using keys).
seized · 3 years ago
Not for other services... I have fail2ban parsing my NVR logs. Wrong password three times and it permanently blocks the IP on my Opnsense firewall.
nvarsj · 3 years ago
And change the sshd port. I use my birth year. 0 brute force attempts in the logs after that.

Deleted Comment

scrps · 3 years ago
And/or run sshd exposed only to a wireguard or tailscale interface.
fireant · 3 years ago
Wow that's a cool evolutionary algorithm in practice! I'm actually surprised it worked, especially with the amount of fuzzing I'd expect ssh ecosystem to receive (well perhaps the servers do, but not the clients haha).
quickthrower2 · 3 years ago
Distributed valgrind
heyoni · 3 years ago
Details!

Seriously this is both hilarious and intriguing and deserves a long form blog post or something.

myself248 · 3 years ago
Seriously, this should be standard practice. Fail2evil...

Dead Comment

saulrh · 3 years ago
Kudos to 185.65.135.x, who attempted to log in with username hn_i_found_it right as I checked HN after work and opened the link, and who proceeded to attempt a number of different simple SQL, html, and js injections. I approve of this effort. I also approve of the author of this site, which appears to have survived this minor attack! :D
koolba · 3 years ago
That’s neat. What’s the total volume per day? Are the passwords themselves being escaped in the final UI rendering? Otherwise you’d have an XSS for a password like “<script>/* code */<script>".

EDIT: Unless it's happening on the server side where it's being saved, I don't think they're being escaped:

    col1.innerHTML = '<span class="fi fi-' + msg.cc + '" title="' + msg.cc + '"></span> ' + msg.src;
    col2.innerHTML = msg.proto;
    col3.innerHTML = '<code>' + msg.u + '</code>';
    col4.innerHTML = '<code>' + msg.p + '</code>';

unlog · 3 years ago
Sorry, but this is not the way. It's like saying, "but I am escaping my inputs on sql with my function"... instead of doing the right thing.

The equivalent code is really not that hard:

    const span = document.createElement('span')
    span.setAttribute('class', 'fi fi'+msg.cc)
    span.setAttribute('title', msg.cc)

    col1.appendChild(span)
    col1.appendChild(document.createTextNode(msg.src))

    col2.textContent = msg.proto

    let code = document.createElement('code')

    code.textContent = msg.u
    col3.appendChild(code)

    code = code.cloneNode(true)
    code.textContent = msg.p
    col4.appendChild(code)

or something in these lines.. you get the idea

mike_d · 3 years ago
It is escaped server side. Anything long enough to be a useful payload is trimmed.
koolba · 3 years ago
How short we talking?

Since there's multiple opportunities to inject code, it's possible to split out the payload across multiple fields: https://www.highseverity.com/2011/06/xss-in-confined-spaces....

Ten characters per block is enough for:

    <script>/*
    */eval(/*
    */'....'+/*
    */'....'+/*
    */'....'+/*
    ...
    */)/*
    */</script>
Best to escape everything at render time.

mike_hock · 3 years ago
As the other comment said, just write proper code instead of going "oh but it's escaped and size-limited."

JS has sane APIs where no string is "dangerous," use them.

vsviridov · 3 years ago
For this reason I've put `endlessh` on port 22 and moved actual ssh elsewhere...

Also started using Crowdsec recently, but not sure about if it's worth it...

fail2ban out of the box works fine for SSH, but for dovecot and postfix it's somehow broken, and the configuration scripts are just too obtuse.

kenniskrag · 3 years ago
Nice idea. From the docs:

Endlessh is an SSH tarpit that very slowly sends an endless, random SSH banner. It keeps SSH clients locked up for hours or even days at a time. The purpose is to put your real SSH server on another port and then let the script kiddies get stuck in this tarpit instead of bothering a real server.

Since the tarpit is in the banner before any cryptographic exchange occurs, this program doesn't depend on any cryptographic libraries. It's a simple, single-threaded, standalone C program. It uses poll() to trap multiple clients at a time.

https://github.com/skeeto/endlessh

avidiax · 3 years ago
I spent 10 minutes to set this up. I was shocked to see that I got my first taker less than a second after I opened port 22 on my firewall.

https://www.abuseipdb.com/check/178.62.237.183

Unfortunately, it only wasted 30 seconds of that IP's time.

It's not clear what type of tarpit would waste the most of the operator's time. Maybe something like a "byzantine VM", that seems exploitable, takes payloads, passes initial checks, and then starts having "problems". DDOS attacks redirect to the C&C server. Coin miners report false mined coins. Hosted files have corruption, and won't complete transfer, etc. Whatever it is, it needs to somehow seem like the operator has an error in their code :)

operator-name · 3 years ago
I'd be cautious about stuff like this - if you annoy the wrong person that could paint a target on your back.
jhartwig · 3 years ago
Wow. That is pretty brilliant.
artursapek · 3 years ago
That’s hilarious
sltkr · 3 years ago
That seems like overkill. I just disable password authentication, and use SSH public keys only. It prevents brute force attacks completely.
ravi-delia · 3 years ago
It's not for security, it's public service and entertainment
BrandoElFollito · 3 years ago
This, and move the endpoint on an uninteresting port to lower the noise in the logs
bootsmann · 3 years ago
Do the dovecot and postfix scenarios work well for you with crowdsec? Always like hearing user stories :)
vsviridov · 3 years ago
I think the blocklists have filtered out a bunch of that noise, so from a straigh-up dovecot logs I've not seen much yet...
chlorion · 3 years ago
I setup SSHD to listen on a wireguard interface rather than listening on all interfaces. This makes SSHD only accessible to wireguard peers rather than the entire internet.

A nice aspect of wireguard is that it's "steath", meaning that it does not respond to unauthenticated connections at all, so there is no way to probe and scan for wireguard listeners at all.

I think setting up daemons behind wireguard offers a lot of security. SSHD is probably fine to expose, but something like an IRC bouncer for example really benefits from being protected I think.

I use ZNC over wireguard for this reason! It also allows to use ZNC securely without the need to setup TLS certs, which IME is actually harder than setting up wireguard!

runeks · 3 years ago
> A nice aspect of wireguard is that it's "steath", meaning that it does not respond to unauthenticated connections at all, so there is no way to probe and scan for wireguard listeners at all.

I did not know this. That’s really cool.

Is it done over a stateless protocol like UDP, or is a TCP connection opened first? Ie. is it impossible to see if there’s even a server there at all, or is it first revealed that there’s a server accepting a TCP connection?

jofla_net · 3 years ago
openvpn has had an option for such behavior (over udp obviously) for a while. the option is called tls-auth, it requires you to go through and generate an aditional key which has to exist on all clients and server. Last i remember is that even if you scan the server, it is completely quiet unless the right signature is received as well for each frame.
omegabravo · 3 years ago
It's over UDP, you can't probe for wireguard AFAIK
ttsiodras · 3 years ago
This is why I come to HN - brilliant ideas that I should have thought of before, but didn't!

I just changed my server, and uninstalled the - now truly useless - fail2ban. I use SSH keys of course, but without fail2ban my server's logs were constantly flooded with hacking attempts.

No longer - wireguard for the win. Thank you, chlorion!

slim · 3 years ago
maybe telnet over wireguard ? :)
yonatan8070 · 3 years ago
That just sounds like SSH with extra steps
koromak · 3 years ago
Its just stupid at this point. You can put up a wordpress site with 5 daily visitors, and you'll still get thousands of SSH / xmlrpc hits per day.
andyp-kw · 3 years ago
The range of IPV4 address's is small enough that a single server can scan it, in a single day.

So I guess the problem isn't going away.

slater · 3 years ago
Man, that one Brazilian IP really going hard
mdaniel · 3 years ago
it bugs me that they're not trying the passwords in lexigraphical order :-D

also, who has sshd without `PermitRootPassword=no`? they need to broaden their horizons and try `admin`, `ec2-user`, and `ubuntu` /s

varenc · 3 years ago
The people with PermitRootPassword=no are also the ones that’ll have weak default password. It’s probably actually saving the attackers time that allowing root password login and bad password choice occur together. If everyone with randomized high-entropy root passwords actually allowed root password logins that bruteforcers would have to spend so much more time!
tjohns · 3 years ago
Who still allows password-based login for any SSH account, root or not? Keys, certificates, or Kerberos for all users.
jovial_cavalier · 3 years ago
Even if you disallow root login with a password, the user can still try to log in, and the attempt still gets logged

If you're asking why it would ever be worth it, there's always valuable stuff online with incompetent configuration. I don't know if shodan is still up, but I remember going on there in high school and getting access to random webcams (sometimes in peoples' homes)

BrandoElFollito · 3 years ago
I do on my home servers where I am the only one and do not need traceability?

Why do you ask, because it is dangerous?

I would love to learn something here.

OptionX · 3 years ago
Yes, someone got a word list. Shame it's a Chinese one.
czbond · 3 years ago
That's what a typical attempt looks like unless they're progressively timed out with fw blocks
channel_t · 3 years ago
This is a pretty excessive amount of SSH brute force but it honestly doesn't seem as bad as some of the cloud machines I run. There are always like at least 3 different IPs going relentlessly hard 24/7/365.
gambiting · 3 years ago
I have an RDP server open to the internet(on a custom port) and it just receives an absolutely relentless stream of login attempts with all kinds of random logins. That's a private server on a private home IP, not associated with a known domain or anything. Changing the port stops it for about 24 hours then it starts again.
costco · 3 years ago
Welcome to the world of "cracked RDP"! Various internet lowlives get a big list of bruteforced RDP IPs/credentials then sell them in bulk: https://www.bleepingcomputer.com/news/security/over-85-000-h.... Sometimes the hacked machines are used to start attacks from.
Solvency · 3 years ago
I know nothing about networking, so pardon the ignorance:

Why isn't there (or is there) some kind of service you can use to map some crazy URL to your personalip:port, like...

http://obscuremyshit.com/393nnasjhf83u98723401 = personalip:port

And only when a connection is referred from that source, does the RDP server even expose itself? And for all other traffic that hits personalip:port, it does absolutely nothing?

m348e912 · 3 years ago
>Why isn't there (or is there) some kind of service you can use to map some crazy URL to your personalip:port,

You might be able to do this by responding with a hyperlink which points to ssh://x.x.x.x:1234

Some browsers will recognize that format and pass to an ssh client application to spawn an appropriate ssh connection.

The reason why it's not a worthwhile idea is that there is a limit of 65535 ports to chose from on a given IP address and they all can be scanned pretty quickly in order to locate an active SSH service port. This really makes the URL idea ineffective.

Port-knocking may be a little bit more effective because the SSH service will not reply to a connection request unless you've attempted to establish a connection on a different port first. Scanning for an open SSH service becomes much more difficult.

fragmede · 3 years ago
There are numerous ways ways around it (port knocking, VPN) that gambiting (for whatever reason) is choosing not to employ. Your idea is a good one though
diarrhea · 3 years ago
That’s how I hide my password manager, but that’s HTTP and has Header fields to dispatch on in the reverse proxy.
KMag · 3 years ago
Is there some referrer field in the RDP protocol handshake that I'm not aware of?
omgmajk · 3 years ago
Yeah, we have the same problem. I made a custom firewall rule and a python script that watches the windows logs for multiple failed logins to combat this and it seems to work pretty well but there's always new ips.
throwaway742 · 3 years ago
Why not VPN?
gambiting · 3 years ago
Because it's a disposable server running in an isolated VM that I need for one reason only and even if someone does break in(impossible with these random logins, and I assume RDP doesn't have any currently known security faults) then it wouldn't be the end of the world - I have a notification on successful login so I'd be told if it ever happened and I would just kill the VM instantly. Right now it's exposed to the internet for simplicity sake.