Author Topic: Taking of back end MSSQL databases with sqlninja  (Read 1211 times)

OneHappyTaco

  • Sr. Member
  • ****
  • Posts: 404
  • Reputation: 11
  • Who Dares Wins
  • Computers: Mac
  • iDevices: Iphone 4s
Taking of back end MSSQL databases with sqlninja
« on: December 02, 2012, 09:31:06 am »
I have another tutorial for you guys. I thought I would make this one before I edited my last one.
Sqlninja is a program used to take over MSSQL websites. To do so, it comes with a variety of tools to gain permissions that will eventually lead up to a takeover. It's a very handy tool. There is only one problem though, it involves brute forcing the password, which quite frankly, almost never works. Usually people these days understand having a strong password is not optional, so in most cases it won't work. Unless of course they didn't change their "sa" password.

To get started you'll need a victim. I suggest your own website, unless you want to break the law. In whichc case, use VPN one click or freeusvpn.com They are both strong and fast servers.


To find a victim, you must first know advanced SQL injection. So you can use a waitfordelay command to find if they use a MSSQL database. I am not going to get into that because even if I did explain the WAITFOR Delay command you would get lost in the config file. All I can say is, find a victim, and set up the config file accordingly.




After you have a victim, a vulnerable page, and the config file set up. We can get started.




You will first fingerprint the website. This means to find out how much power you have over the site. Basically, what you can an can't do. You do this by typing:




./sqlninja -m fingerprint



Here is a screenshot of the fingerprint:




Now I will be covering a worst case seneraio. This is when the xp_cmdshell isn't working and you are not "sa," or the admin.

Now since we have a lot to deal with, let's start with a brute force of the "sa" password to gain more rights on the site. Simply type this in:



sqlninja -m bruteforce -f (the path to the word list)




This will probably take 30 mins to bruteforce considering you have an ok word list. During which time, you will most likely be praying to the dear lord the idiot running the site has no numbers in his password, or capitals. Now if you get a success, that means your word list worked. Now let's say the password was:
password
Then all our commands will end in a "-p password"
Now after we have the password let's run a simple reactivate of the xp_cmdshell. Type in





./sqlninja -m x -p password


No most likely it will not work, but in some cases it might say this:
« Last Edit: December 02, 2012, 03:29:03 pm by OneHappyTaco »

Alex47

  • Hero Member
  • *****
  • Posts: 1370
  • Reputation: 48
  • (I can't think of something funny to go here)
  • Computers: Asus k55v, custom built self-acclaimed tank of a pc
  • iDevices: iPhone 3G, iPod touch 4g, iPod touch 2g
Re: Taking of back end MSSQL databases with sqlninja
« Reply #1 on: December 02, 2012, 10:14:11 am »
Nice tutorial, however you didn't say how to setup config file properly, you just told us to do it. and work a bit on the formatting.

Otherwise well done, the content is good, however it is not as clear as it could have been :)
« Last Edit: December 02, 2012, 10:54:05 am by alex47 »
My Number:00110110 00110110 00110110

Hanoko

  • Full Member
  • ***
  • Posts: 188
  • Reputation: 7
  • Listen to my radio www.radioldies.com
    • Oldies Radio
  • Computers: Windows XP, Airis ONE Pad 700
  • iDevices: Ipod Touch 3G 8GB
Re: Taking of back end MSSQL databases with sqlninja
« Reply #2 on: December 02, 2012, 02:28:01 pm »
You should say how to set up the config file.

Languages I know:
PHP
HTML
CSS
Javascript(Basic)

OneHappyTaco

  • Sr. Member
  • ****
  • Posts: 404
  • Reputation: 11
  • Who Dares Wins
  • Computers: Mac
  • iDevices: Iphone 4s
Re: Taking of back end MSSQL databases with sqlninja
« Reply #3 on: December 02, 2012, 03:03:54 pm »
It's too extensive. There are way too many things to cover. Plus it tells you right in the config file how to do it.

A12danrulz

  • Leader
  • Hero Member
  • *****
  • Posts: 4018
  • Reputation: 217
  • Badges:
Re: Taking of back end MSSQL databases with sqlninja
« Reply #4 on: December 02, 2012, 05:11:59 pm »
If you make a tutorial, maybe you should make a tutorial instead of a list of commands. And when people have questions, help them instead of telling them they are on their own.

Don't like seeing ads? Click here to register!

h4ck3rpr0n3

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3063
  • Reputation: 130
  • Developer, Genius :P :P
  • Badges:
  • Computers: HP Pavillion g7: Windows 7, BT5 R1, Ubuntu 12.04, Windows 8, Linux Mint
  • iDevices: ipod touch 3g, ipod touch 2g
Re: Taking of back end MSSQL databases with sqlninja
« Reply #5 on: December 02, 2012, 05:25:43 pm »
I agree with A12, and have you seen some of the tutorials around here? Extensive is good, it helps people understand and have fewer questions. When someone reads your tutorial they shouldn't have too many questions over it. The more indepth it is the better it will be and that reflects on you in a way.
goals:
[] get developer status
[X] get 30+ karma
[X] get to hero member
[X] become part of the staff

languages i know:
JavaScript
CSS
HTML
PHP
C
C++
Cython
Python

OneHappyTaco

  • Sr. Member
  • ****
  • Posts: 404
  • Reputation: 11
  • Who Dares Wins
  • Computers: Mac
  • iDevices: Iphone 4s
Re: Taking of back end MSSQL databases with sqlninja
« Reply #6 on: December 02, 2012, 06:03:31 pm »
I understan what your trying to say. As you can see it's not finished yet. Too use sqlninja you will have to know basic to advanced sql injection. It uses exploit strings, vulnerable pages, and I can't teach two months worth of sql injection in one tutorial.

Ironman

  • Administrator
  • Hero Member
  • *****
  • Posts: 5113
  • Reputation: 252
  • Badges:
  • Computers: ASUS UL50VT
  • iDevices: iPhone 5, iPhone 4S, iPhone 4, iPhone 3GS
Re: Taking of back end MSSQL databases with sqlninja
« Reply #7 on: December 02, 2012, 10:56:19 pm »
Maybe a tutorial on basic SQL injection to start and work up from there would be better. Take noobs through it from the start of basic then to advanced. I think this is a subject that is to good to not have on the forum.
Click for How to Add Our Repo
If you're going to ask questions....
At least make them good ones.

Knowledge is the one thing that can never be taken from you

h4ck3rpr0n3

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3063
  • Reputation: 130
  • Developer, Genius :P :P
  • Badges:
  • Computers: HP Pavillion g7: Windows 7, BT5 R1, Ubuntu 12.04, Windows 8, Linux Mint
  • iDevices: ipod touch 3g, ipod touch 2g
Re: Taking of back end MSSQL databases with sqlninja
« Reply #8 on: December 02, 2012, 10:59:32 pm »
^I agree. SQL Injection is an undisposable tool and it comes in handy to have on your belt of things you know.
goals:
[] get developer status
[X] get 30+ karma
[X] get to hero member
[X] become part of the staff

languages i know:
JavaScript
CSS
HTML
PHP
C
C++
Cython
Python

grinch

  • Administrator
  • Hero Member
  • *****
  • Posts: 1933
  • Reputation: 188
  • the digital grinch who stole your data
    • @DigitalGrinch
  • Badges:
  • iDevices: iPhone 3GS 4.3.3, HTC Evo V 4G ICS
Re: Taking of back end MSSQL databases with sqlninja
« Reply #9 on: December 07, 2012, 01:13:43 pm »
This is not finished. This is like sending a car off the assembly line without an engine or doors
Make your "tutorials" offline, then post when they are done. This will enable you to actually make a usable tutorial, instead of just posting some commands and expecting people to read your mind
If I help you or you appreciate my work, clicking that +1 button is the best thanks I could get.

My opinions are my own, you may agree or disagree with them, but they are only just that; opinions
For example: facebook is the microsoft of social networks

http://goo.gl/PiVjI

@DigitalGrinch
https://twitter.com/DigitalGrinch

I follow all iNinjas members back. PM me if I am not following you

Don't like seeing ads? Click here to register!

[null]

  • Hero Member
  • *****
  • Posts: 646
  • Reputation: 42
  • the halloween jack is a real cool cat
  • Computers: I have a PC running Windows 7 that was built by my uncle. I also have a Newsmy T3 Android Tablet.
  • iDevices: iPod Touch 4G
Re: Taking of back end MSSQL databases with sqlninja
« Reply #10 on: December 14, 2012, 02:56:37 pm »
This is not finished. This is like sending a car off the assembly line without an engine or doors
Make your "tutorials" offline, then post when they are done. This will enable you to actually make a usable tutorial, instead of just posting some commands and expecting people to read your mind
Good advice. I always type up my tutorials in the 'Notes' app beforehand, and it helps me catch a lot of spelling and gramatical errors, as well as make sure the tut is polished before posting.
__  __           ___    ___          
/\ \/\ \         /\_ \  /\_ \          
\ \ `\\ \  __  __\//\ \ \//\ \     
 \ \ , ` \/\ \/\ \ \ \ \  \ \ \          
  \ \ \`\ \ \ \_\ \ \_\ \_ \_\ \_
   \ \_\ \_\ \____/ /\____\/\____\
    \/_/\/_/\/___/  \/____/\/____/