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 @fwrite
($fp, "[<a href=\"//\">//</a>]\n"); //Unix root (if running unix)
66 $dsks = "cdefghijklmnopqrstuvwxyz"; //Show this volumes (if available)
67 for($i=0;$i<strlen($dsks);$i++
) {
68 if(is_dir($dsks[$i].":")) {
70 @fwrite
($fp, "[<a href=\"/$vol:/\">$vol:</a>]\n");
72 //echo($dsks[$i].":");
74 @fwrite
($fp, "<br />\n\n");
77 @fwrite
($fp, "<b>Directory listing of $directory :</b><br /><br />\n\n");
78 @fwrite
($fp, "[DIR] <a href=\"./../\">Parent Directory (../)</a><br />\n");
79 $files=opendir ($directory);
80 while (false!==($file = readdir($files)))
82 if ($file != "." && $file != "..")
85 if(is_dir("$directory/$file")) {
86 fwrite($fp, "$num - [DIR] <a href=\"./$file\">$file</a><br />\n");
88 fwrite($fp, "$num - <a href=\"./$file\">$file</a><br />\n");
94 fwrite($fp, "<br />\n<b>Total: $num</b>\n</tt></body>\n</html>");
97 ///CODE///////////////////////////////////////////////////////////////////////////
98 echo("\n\tStarting Harvie's HTTPd at:\n\ttcp://$interface:$port\n\n");
99 //system("title Harvie's HTTPd at tcp://$interface:$port"); //Microsoft Windows only
101 $sss = stream_socket_server("tcp://$interface:$port");
104 @$sfp = stream_socket_accept($sss);
108 while($sfp && !@feof
($sfp) && $loop) {
111 if(eregi("(GET|POST)", $line)) {
114 $line = explode(" ", $line);
116 $line[1] = trim(urldecode($line[1]));
119 if($line[1] == "/") {
122 $line[1] = substr($line[1], 1);
126 if(is_file($line[1])) { //200 OK FILE
127 fwrite($sfp, $okheader);
128 echo("200 ".$line[1]);
129 $fp = fopen($line[1], "rb");
130 while( fwrite($sfp, fgets($fp)) );
135 elseif(is_dir($line[1])) { //200 OK DIR
136 if(substr($line[1], strlen($line[1])-1) != "/") { //301 MOV DIR
137 $header = ("/".$line[1]."/");
138 echo("301 ".$line[1]." -> $header\n");
139 $header = str_replace("%DIR%", $header, $dirheader);
140 //$header = str_replace("./", "./", $dirheader);
142 fwrite($sfp, $header);
146 echo("200 [DIR] ".$line[1]."\n");
147 send_dir_listing($sfp, $line[1]);
150 else { //404 NOT FOUND
151 echo("404 ".$line[1]."\n");
152 fwrite($sfp, $badheader);
153 fwrite($sfp, $err404);
This page took 1.267501 seconds and 4 git commands to generate.