Six Ways a Russian Hacker Attacked My Website
Tags: webdev, javascript, programming
Published: 2020-03-16 10:43:40

<h1 align="center">Six Ways a Russian Hacker Attacked My Website</h1>
<p align="center"><img src="https://dev-to-uploads.s3.amazonaws.com/i/3kscsp11eepwetue9aym.png" align="center" width="70%" alt="search bar injection"/></p>
<p>Until today, the "russian hacker" seemed like a piece of news-hyped fantasy. It turns out, that just isn't the case. They're real. They've attacked me, and they can attack you.</p>
<p>I want to be very clear at the head of this, this article features REAL links to this russian hacker's files and everything I was able to trace back to him. I did not candy-coat anything at all. If you're uncomfortable clicking those links, don't. If you choose to click the links, use a VPN, avoid running his files on your computer, and be safe. I'm not responsible for anything that happens if you interact with his stuff.</p>
<p>As you may have guessed after seeing my intro image, the hacker attacked me with <b>injections</b> through an input on my webpage. Put simply, he typed code into a search bar to see if he could get my server to do what he wanted it to do instead of what I was telling it to do. Had I not been properly sanitizing the data I was collecting from this input, he would have been successful.</p>
<p>Now, I'm not going to dance around what happened or try to tell you anything in an abstract way. I think it's important to know what hackers are trying these days so we know how to best protect ourselves. So, I've decided to include an actual screenshot of the "searches" this hacker typed into my search bar here.</p>
<p align="center"><img src="https://dev-to-uploads.s3.amazonaws.com/i/1h44fdj817loa69l72fo.png" align="center" width="70%" alt="injection attempts"/></p>
<p>You can ignore the 0's at the end of each line and the "groupSites0" at the beginning of each line. Those are search filters that have nothing to do with the malicious aspect of each of these searches. Let's get to the meat of these attack methods.</p>
<h2>Attack #1: "etc/group" file searching</h2>
<p>"<a href="https://www.cyberciti.biz/faq/understanding-etcgroup-file/">etc/group</a>" files are something I just learned about, and that's part of the reason this article is listed as a "discussion" piece. I'll tell you what I know, and please let me know in the comments if you have more to offer. To my knowledge, this hacker was assuming I use a Linix/UNIX operating system for my server. With Linix/UNIX operating systems, etc/group files contain a list of all users that have permissions for the server, which would be a great thing to have if you were trying to pretend to be me and gain access to my backend. The "../" here just means that he's trying to access parent directories within my backend's filesystem. That's not hugely relevant to the attack method here.</p>
<h2>Attack #2: FTP file injection</h2>
<p>This is by far my favorite attack that the hacker used. He was trying to upload a file to my server from his own, but he wasn't counting on me recording his searches for database backup purposes. By trying to connect his FTP to my server, he gave me access to his files. You see that URL in line 671 above? That's his real FTP, and you can visit it at <a href="ftp://ref:ref@dahli.rosinter.ru:21">ftp://ref:ref@dahli.rosinter.ru:21</a>, though I'll save you the trouble if you are understandably wary. I'm including a screenshot of his files available at that link here.</p>
<p align="center"><img src="https://dev-to-uploads.s3.amazonaws.com/i/o1r7oxj8jo8f9d92qj56.png" align="center" width="70%" alt="injection attempts"/></p>
<p>He has a lot of files about a company called <a href="https://www.qlik.com/us/">Qlik</a>, and his FTP's <a href="http://rosinter.ru">parent domain</a> either is or is pretending to be a Russian food company. That <a href="ftp://ref:ref@dahli.rosinter.ru/test.txt">test.txt</a> file you see there is what he was trying to upload to my server. What's in it? Nothing actually harmful, just a bit ominous.</p>
<p align="center"><img src="https://dev-to-uploads.s3.amazonaws.com/i/zz3qcdecv1y64nsz7qay.png" align="center" width="70%" alt="injection attempts"/></p>
<h2>Attack #3: "phpinfo" probing</h2>
<p><a href="https://www.php.net/manual/en/function.phpinfo.php">phpinfo</a> basically tells you everything about my PHP settings. It'll tell you what version of PHP I'm operating on, how long I let scripts run for before automatically terminating them, what environment variables I'm trying to hide from prying eyes, and a ton of other juicy goodies. But really, what the hacker is looking for here is just to see whether he can get any info out of me at all. Before trying to figure out what my thousands of users' passwords are, it's easier to ask for phpinfo to see if I'm even vulnerable to an attack in the first place.</p>
<h2>Attack #4: Base64 injection</h2>
<p>This one's another phpinfo probe in disguise. Base64 strings are usually used as the text-formatted version of images, but this one is the text format of a PHP file. And when you decode <b>data:;base64,PD9waHAgcGhwaW5mbygpOyA/Pg==</b>, guess command you get? That's right, &lt;?php phpinfo(); ?&gt;. Feel free to try it yourself <a href="https://base64.guru/converter/decode/image">here</a>.</p>
<h2>Attack #5: Further "etc/group" file searching</h2>
<p>The attacker had no luck with his first "etc/group" file search, so he figured it'd be worth one more go in a different directory. No luck there either, but nice try.</p>
<h2>Attack #6: w;w;w</h2>
<p>I actually don't get this one. It almost seems like he's trying to set write permissions for himself? I'd love if the community could chip in in the comment section to let me know what this could be.</p>
<h2>The Scariest Part...</h2>
<p>I timestamp every search that goes into my searchbar. Every single one of these six searches were executed within a timespan of <b>30 seconds</b> (from 6:36:32 AM through 6:36:59 AM). That means this person has this whole process automated. He goes from site to site, poking around to find any holes that he can exploit, and when he finds one, he knows plenty of ways to take advantage and get what he wants. And he does it all through VPN connections that don't trace back to him. If you're interested, here are the IPs he used:</p>
<ul>
    <li>82.150.140.160 (not blacklisted, in Amsterdam, Netherlands)</li>
	<li>79.170.40.224 (blacklisted, in London, UK)</li>
	<li>79.170.40.225 (heavily blacklisted, in London, UK)</li>
</ul>
<p>Please use this as an opportunity to learn and take caution with your development. Not everyone plays by the rules.</p>
<p>--</p>
<p><a href="https://dev.to/nastyox1">nastyox</a></p>