Sunday, August 16, 2009

JALH (Just Another Lame Hack)

Not lame, the lamest. I won't describe this with every detail, it was just too lame. I was trying some other URL SQL Injections on Lamer (without any great success) when found something weird. 

When submitting a post on forum I was looking in Fiddler for the post data. And I found my username and user ID within. I thought it's a bad joke, a remnant from an old version... I mean my username was in the cookie with my coded password (long term cookies for "remember me" for a year or so logins), why require it on form... in hidden inputs. It wasn't hidden at all.

I copied the site to a local HTML file, replaced every relative path (./) to absolute ones (http://lamer_domain.top_level_domain/) with Notepad++, removed the type="hidden" attributes of the inputs, and opened it.

There was a form, where I couldn't just post a text, but I could specify the one posting it. Guess what, I picked the administrator (user ID 2). Well, I'm a l33t, at least I've done this on the test-page, so no real user was reading it.

I think that's all about Lamer. When I was first asked to hack Lamer, I was thinking that 5 successful attempts will be more than enough to be acknowledged as somebody important, so this is the point where I'll stop hunting, this was the fifth chance to do something a normal user shouldn't do. Lamer isn't lame any more, moreover, never really was. I still think it's the best site ever, and hope one day I'll be one of it's programmers. But don't worry, the world is full of hackable things, and this blog will be alive until the whole world won't become smarter than I am.

The more I hack the more ideas I get to hack. So please stand by, very soon you'll hear about me.

Friday, August 14, 2009

Hacking my own ISP

As you know ISP stands for Internet Service Provider, those guys who let you connect to the Internet, usually over against a particular amount of fee. The title says hack, but it's not really a hack, but a pretty good bug exploit.

It was before a festival, some guys got in trouble for a dirty business (nothing happened after all), but I got acquainted with one of them. He was a real hacker, without the slightest knowledge of programming. He has his own "friends", passwords, programs and money-making prospect (and I'm not talking about working here, it's more like stealing).

He lives close to me, close enough to have the same ISP. He told me that our Internet Service has a bug. Our provider gives dynamic IP (for me became static since I have router and not turning off too often), which I knew about. The trick I didn't knew, was that different IP addresses got different bandwidths. Inside the local network (it's larger than the whole city) there's about 2-5 MB/s speed, outside is 255-500 KB/s. But there are a few IP addresses which got more then 5 MB/s speed outside of the local network.

That was the time he became my costumer. I had programming knowledge, and he had every other. Helped me a lot to create the bot, which search for the owning IP. It was simple: connect, calculate the bandwidth, if it was good enough exit, else disconnect and start over. For connecting and disconnecting I used RasDial, for bandwidth calculation RapidShare. The whole thing was implemented in C#.

A little reference for both of them:

I think the second link is a broken one, or just the server is down temporary, either way I'll post my complete source code:

The program is very simple. I created a file (it's size is 1MB, but it can be changed), which is uploaded each time the bandwidth is calculated. The calculation is simple too, measure the time, and divide the uploaded file's size with it, then convert to KB/s.

To sum up, this wasn't that great of a hack. These IP's would have been allocated for users anyway, and a user could get access manually too, I just created a search bot to speed up the process. And I never taught about telling anyone in charge, I mean who don't wants speed? And why not to use it, if there's already outside somewhere?

If you have a dynamic IP, RasDial with the BotNet presented in the previous post can be used on anonymous voting polls. Vote, change IP and vote again (and do not accept any cookie). Maybe someday I'll create a software for that too. Another use would be brute-forcing logins. It's rustic but impossible to create defense against it. At least I couldn't do it.

But for now, I'll stay on Lamer, and attack it for a few more times.

Wednesday, August 12, 2009

Forth Attack: Click-Fraud-Bot (part 2)

At first I was thinking to get a simple browser with an open code written in C#, and use it's source to learn. After all, I needed an automated browser. But that was too complicated because I didn't needed the visualization of the response, just the request and response headers. And briefly the body too. But a whole browser was just too much. And anyway, most of them used premade libraries, which knew too much. Eh, I wanted a bit control.

After a bit research I decided to use the HttpWebRequest and HttpWebResponse classes, and wrote my own Browser class.

Source codes:

I used Fiddler 2 for creating the headers. I visited the website using Internet Explorer while Fiddler was opened. It's a web debugger, working as a local proxy, monitoring all incoming and outgoing requests. By comparing the headers created by IE and those crated by my program I could get a good job pretty fast.

The biggest problem were cookies. The site needed them, a non-member user can't do almost anything. Cookies most be stored then reseeded, but I just couldn't find where did they appeared. I squandered a whole day just with cookies. But after all it came out pretty good.

I regretted using C#. It's damn slow. My program too, I know, but still... it was running for a half an hour. But the result worth everything.  I got a .txt file with more than 30000 E-Mail addresses. It wasn't completely clear, tho, because some users used their E-mail as their User ID, and by doing this they screwed 2 other e-mails. It happened thanks to an option on the profile page of visiting the previous and next profiles, these being at the top of the page. Another problem was if users used @ in other fields like Name.

After another 20 minutes of clearing the text document, I finally got what I desired. Pure 30500 E-Mail addresses each one in a single line. Each of them validated and unique (but maybe deprecated).

Think about it. You have a business, great services for low price, but no one knows about you. Me, as your good friend, offer you 100 E-Mail addresses for 1 dollar. I think at least 20 will read it, 3 of them will get interested, and 2 of them will buy your service, and let's say one of them will return to you in the future. If every service earns you lets say 10$, you earned with this around 25$. By paying me 1$. Not a bad business so far right? OK, now let's think big. I sell you all of them, each 100 E-mail address 1$. I will earn 300$ and you around 500 costumer. The only loser is the administrator.

The worst is, I could have used this bot in a much better way. The site offered an E-Mail system too, you fill a form and it sends an E-Mail. I found a bug, whereby you could send E-Mail to those members as well who hid their E-Mail addresses (with simple URL SQL Injection). This way, I could have sent at least one E-Mail to 52000 user, and not being afraid that my IP and E-mail or those used to E-Mail gets to a black list, blocked, become spammer suspect and so on. After all it was the server who sent the E-Mails.

That's all. Nothing happened on your server, but one day you see that Mozilla is giving you a warning, Opera won't let you proceed to your own website, you get errors while sending E-Mails, your ISP is coming for you... big problems. Protect sensitive information!

What's the solution?

Sensitive information shouldn't be displayed as plain HTML. Use JavaScript to divide string. Example:


<script type="text/javascript">
at = '@';
document.write('mai'+'lto:'+'myemai'+'laddress'+at+'myemailpr'+'ovider');
</script>

The best would be to randomly cut up the string using PHP, put inside empty strings with random names, name string parts using random names then use as should, briefly randomly generate this JavaScript from PHP. The more complicated is the more secure will get.

Another method to secure would be to generate an image, which contains the E-Mail address. You can do this from PHP:


<?php
header("Content-type: image/jpeg");

$Str = "myemailaddress@myemailprovider.domain";
$NewImage = imagecreatefromjpeg("img.jpg");
$red = 50; $green = 50; $blue = 255;
$TextColor = imagecolorallocate($NewImage, $red, $green, $blue);
$fontSize = 8; $posX = 0; $posY = 0;
imagestring($NewImage, $fontSize, $posX, $posY, $Str, $TextColor);

imagejpeg($NewImage);
?>

If ./img.jpg looks like this:

the result is:


Much harder to hack (don't think it's impossible). This image was generated on my local server.

Stand by, very soon another post will come.