Spiga

SQL INJECTION WITH EXAMPLE


Some More Example Of SQL INJECTION


Continued from the last post,in this post, we will see some real example of the SQL Injection.

For the LOGIN Form :-


user:admin (you dont even have to put this.)

pass:' or 1=1--


or


user:' or 1=1--

admin:' or 1=1--


some sites will have just a password so


password:' or 1=1--



The injection attack has actually made our query behave differently than we intended. By using a single quote (') they have ended the string part of our MySQL query
username = ' '
and then added on to our WHERE statement with an OR clause of 1 (always true).
username = ' ' OR 1
This OR clause of 1 will always be true and so every single entry in the "customers" table would be selected by this statement!


Although the above example displayed a situation where an attacker could possibly get access to a lot of information they shouldn't have, the attacks can be a lot worse. For example an attacker could empty out a table by executing a DELETE statement.

MySQL & PHP Code:


$name_evil = "'; DELETE FROM customers WHERE 1 or username = '";
// our MySQL query builder really should check for injection
$query_evil = "SELECT * FROM customers WHERE username = '$name_evil'";
// the new evil injection query would include a DELETE statement
echo "Injection: " . $query_evil;

Display:


SELECT * FROM customers WHERE username = ' '; DELETE FROM customers WHERE 1 or username = ' '
If you were run this query, then the injected DELETE statement would completely empty your "customers" table.

SQL INJECTION


SQL Injection

SQL injection is a strong password cracking technique that exploits a security vulnerability occurring in the database layer of an application.SQL Injection is subset of the an unverified/unsanitized user input vulnerability ("buffer overflows" are a different subset), and the idea is to convince the application to run SQL code that was not intended. If the application is creating SQL strings naively on the fly and then running them, it's straightforward to create some real surprises.

The primary form of SQL injection consists of direct insertion of code into user-input variables that are concatenated with SQL commands and executed. A less direct attack injects malicious code into strings that are destined for storage in a table or as metadata. When the stored strings are subsequently concatenated into a dynamic SQL command, the malicious code is executed.
The injection process works by prematurely terminating a text string and appending a new command. Because the inserted command may have additional strings appended to it before it is executed, the malefactor terminates the injected string with a comment mark "--". Subsequent text is ignored at execution time.

Example:
var Shipcity;
ShipCity = Request.form ("ShipCity");
var sql = "select * from OrdersTable where ShipCity = '" + ShipCity + "'";

The user is prompted to enter the name of a city. If she enters Redmond, the query assembled by the script looks similar to the following:
SELECT * FROM OrdersTable WHERE ShipCity = 'Redmond'
However, assume that the user enters the following:
Redmond'; drop table OrdersTable--
In this case, the following query is assembled by the script:
SELECT * FROM OrdersTable WHERE ShipCity = 'Redmond';drop table OrdersTable--'
The semicolon (;) denotes the end of one query and the start of another. The double hyphen (--) indicates that the rest of the current line is a comment and should be ignored. If the modified code is syntactically correct, it will be executed by the server. When SQL Server processes this statement, SQL Server will first select all records in OrdersTable where ShipCity is Redmond. Then, SQL Server will drop OrdersTable.
As long as injected SQL code is syntactically correct, tampering cannot be detected programmatically. Therefore, you must validate all user input and carefully review code that executes constructed SQL commands in the server that you are using. Coding best practices are described in the following sections in this topic.


Input character      Meaning in Transact-SQL

;                        Query delimiter.

'                       Character data string delimiter.

--                   Comment delimiter.

/* ... */                     Comment delimiters. Text between /* and */ is not evaluated by the server.

xp_                   Used at the start of the name of catalog-extended stored procedures, such as xp_cmdshell.

NMAP UTILITY


How To Handle NMAP


NMAP is one of the best tool for knowing the target information.This can be used as follows:-


Download the NMAP as said in the last post.Install the NMAP.exe file.In the command prompt type nmap and its options.Its options are:


Nmap 4.20 ( http://insecure.org/ )

Usage: nmap [Scan Type(s)] [Options] {target specification}

TARGET SPECIFICATION:

Can pass hostnames, IP addresses, networks, etc.

Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254

-iL : Input from list of hosts/networks

-iR : Choose random targets

--exclude : Exclude hosts/networks

--excludefile : Exclude list from file


HOST DISCOVERY:

-sL: List Scan - simply list targets to scan

-sP: Ping Scan - go no further than determining if host is online

-P0: Treat all hosts as online -- skip host discovery

-PS/PA/PU [portlist]: TCP SYN/ACK or UDP discovery to given ports

-PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes

-n/-R: Never do DNS resolution/Always resolve [default: sometimes]

--dns-servers : Specify custom DNS servers

--system-dns: Use OS's DNS resolver


SCAN TECHNIQUES:

-sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans

-sU: UDP Scan

-sN/sF/sX: TCP Null, FIN, and Xmas scans

--scanflags : Customize TCP scan flags

-sI : Idlescan

-sO: IP protocol scan

-b : FTP bounce scan


PORT SPECIFICATION AND SCAN ORDER:

-p : Only scan specified ports

Ex: -p22; -p1-65535;

-p U:53,111,137,T:21-25,80,139,8080

-F: Fast - Scan only the ports listed in the nmap-services file)

-r: Scan ports consecutively - don't randomize


SERVICE/VERSION DETECTION:

-sV: Probe open ports to determine service/version info

--version-intensity : Set from 0 (light) to 9 (try all probes)

--version-light: Limit to most likely probes (intensity 2)

--version-all: Try every single probe (intensity 9)

--version-trace: Show detailed version scan activity (for debugging)


OS DETECTION:

-O: Enable OS detection (try 2nd generation w/fallback to 1st)

-O2: Only use the new OS detection system (no fallback)

-O1: Only use the old (1st generation) OS detection system

--osscan-limit: Limit OS detection to promising targets

--osscan-guess: Guess OS more aggressively


TIMING AND PERFORMANCE:

Options which take

-T[0-5]: Set timing template (higher is faster)

--min-hostgroup/max-hostgroup : Parallel host scan group sizes

--min-parallelism/max-parallelism

--min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout

--max-retries : Caps number of port scan probe retransmissions.

--host-timeout

--scan-delay/--max-scan-delay


FIREWALL/IDS EVASION AND SPOOFING:

-f; --mtu : fragment packets (optionally w/given MTU)

-D : Cloak a scan with decoys

-S : Spoof source address

-e : Use specified interface

-g/--source-port : Use given port number

--data-length : Append random data to sent packets

--ip-options : Send packets with specified ip options

--ttl : Set IP time-to-live field

--spoof-mac : Spoof your MAC address

--badsum: Send packets with a bogus TCP/UDP checksum


OUTPUT:

-oN/-oX/-oS/-oG : Output scan in normal, XML, s
-oA : Output in the three major formats at once

-v: Increase verbosity level (use twice for more effect)

-d[level]: Set or increase debugging level (Up to 9 is meaningful)

--open: Only show open (or possibly open) ports

--packet-trace: Show all packets sent and received

--iflist: Print host interfaces and routes (for debugging)

--log-errors: Log errors/warnings to the normal-format output file

--append-output: Append to rather than clobber specified output files

--resume : Resume an aborted scan

--stylesheet : XSL stylesheet to transform XML output to HTML

--webxml: Reference stylesheet from Insecure.Org for more portable XML

--no-stylesheet: Prevent associating of XSL stylesheet w/XML output


MISC:

-6: Enable IPv6 scanning

-A: Enables OS detection and Version detection

--datadir : Specify custom Nmap data file location

--send-eth/--send-ip: Send using raw ethernet frames or IP packets

--privileged: Assume that the user is fully privileged

--unprivileged: Assume the user lacks raw socket privileges

-V: Print version number

-h: Print this help summary page.


EXAMPLES:

nmap -v -A scanme.nmap.org

nmap -v -sP 192.168.0.0/16 10.0.0.0/8

nmap -v -iR 10000 -P0 -p 80

BEST HACKING TOOLS

mynetsecurity

Hacking Tools


These are the best third hacking tools.

1)NMap:

To Download NMap click here

2)Netcat

To Download Netcat click here

3)EnumSolarWinds TFTP Server

4)Teleport Pro

To Download Teleport pro click here


Microsoft utilities:


1)TFTP

2)NBTSTAT

3)PING

4)TRACERT

5)NET

6)ARP

7)IPCONFIG

You can run this utilities directly by typing this command in the run command prompt.

MOBILE HACKS-II

mynetsecurity.blogspot.com

Blocking Cell Phone Number From Seen in Caller IDs


Freinds after reading this article you will be able to block your cell phone number from showing up on other people's caller IDs. It's very simple to block your cell phone number. You have two options: you can permanently block your phone number or you can block your number on a call by call basis.


Blocking Your Cell Phone Number Permanently:


The most permanent solution is to request a "line block" from your cell phone carrier.

1) To do this you simply need to call the customer service for your specific provider and they can block your number. When you do this your number will never show up to anyone.

2) To call your customer service to block your cell phone number, just dial 611 from your cell phone and you will reach them.


3) If there is a situation where you want your number to show up, you will still have an option. When you have a permanent block on your cell phone number you will need to dial *82 before dialing the number you are calling. When you do this your phone number will show up just once for that specific call. Ex: *82 (555) 555-5555.


Blocking Your Cell Phone Number Temporarily:


Sometimes you may want to block you number for a specific call. You might not want someone to know that you are trying to reach them for the 15th time in a row, or you might be calling a business and might not want them to know your number.

1) If you want to block your cell phone number on a call by call basis you need to dial *67 before dialing the number. Ex *67 (555) 555-5555.

2) When you do this you will not have any feedback that it worked. If you want to test this, just call your home phone, or anther phone that has a caller ID from your cell to confirm that your phone number is blocked.


NOTE:One important thing to remember is that your number will not be blocked from emergency services or any toll free numbers.



How to Find the Owner of a Cell Phone Number:


If you want to identify and unidentified phone number you can with reverse phone number search websites. You can do free reverse phone number search at http://www.infospace.com/ but if you want to find out who owns a cell phone number then use http://www.cellreversesearch.com/.



Steps
1 Step One
Go to www.cellreversesearch.com
2 Step Two
Enter any phone number
3 Step Three
Hit Search
4 Step Four
Check Results
5 Step Five
Sign up for owner's name, address and cell phone account history information

BLUESNARFING-Another Hacking Technique


Bluesnarfing-Mobile Hacking

What is Bluesnarfing?
Ans:Bluesnarfing is the unauthorized access of information from a wireless device through a bluetooth connection, often between phones, desktops, laptops, and PDAs that allows access to calendar, contact list, emails and text messages, and on some phones users can steal pictures and private videos,from Mobile or any other bluetooth device.


Watch video for Bluesnarfing




BlueSnarf exploits weak OBEX implementation on mobile phoneBlueSnarfexploitsweakOBEXimplementationonmobilephonesOPP: Object push profile, unauthorised access, for vCardOPP:Objectpushprofile,unauthorisedaccess,for vCardsSYNCH: Profile for exchange of private dataSYNCH:ProfileforexchangeofprivatedataCalendar, contacts, pictures, …Calendar,contacts,pictures,…Authorised access!Authorisedaccess!.Adv connects to OBEX push profileNo authentication, no pairing needed .invisible connection .In vulnerable implementations:.SYNCH profile exists parallel to OPP .Adv: retrieve files via filenames .Unauthorised, via OPP profile !!! .e.g. GET telecom/pb.vcf (contacts) Bluetooth being short range technology: NO security feature!

Method
In order to perfom a BlueSnarf attack, the attacker needs to connect to the OBEX Push Profile (OPP), which has been specified for the easy exchange of business cards and other objects. In most of the cases, this service does not require authentication. Missing authentication is not a problem for OBEX Push, as long as everything is implemented correctly. The BlueSnarf attack connects to an OBEX Push target and performs an OBEX GET request for known filenames such as 'telecom/pb.vcf' for the devices phone book or 'telecom/cal.vcs' for the devices calendar file. (There are many more names of files in the IrMC Specification). In case of improper implementation of the device firmware, an attacker is able to retrieve all files where the name is either known or guessed correctly.