This commit is contained in:
Fox 2023-12-06 01:12:40 +00:00
parent 8a09f2be00
commit fd36c9d87b
2 changed files with 44 additions and 1 deletions

View File

@ -10,8 +10,11 @@
### 1a. Set up API for `Are links vulnerable to MITM attack?`(isMM) ### 1a. Set up API for `Are links vulnerable to MITM attack?`(isMM)
Pick A or B.
> Type A: download JSON files and use them locally
1. Copy [ismm.php](ismm.php) to your website directory.<br> 1. Copy [ismm.php](ismm.php) to your website directory.<br>
e.g. `/api/ismm.php` e.g. `/api/ismm.php` (you can rename it)
2. Create `listdata` directory.<br> 2. Create `listdata` directory.<br>
e.g. `/api/listdata/` e.g. `/api/listdata/`
3. Download JSON files (*.json) from [/cloudflare_users/domains](../../cloudflare_users/domains) and save them to dir above.<br> 3. Download JSON files (*.json) from [/cloudflare_users/domains](../../cloudflare_users/domains) and save them to dir above.<br>
@ -20,6 +23,12 @@
4. Open your API. It should say `OK`.<br> 4. Open your API. It should say `OK`.<br>
e.g. `http://localhost/api/ismm.php` e.g. `http://localhost/api/ismm.php`
> Type B: Use KarmaAPI online service
1. Copy [ismm_online.php](ismm_online.php) to your website directory.<br>
e.g. `/api/ismm_online.php` (you can rename it)
2. Open your API. It should say `OK`.<br>
e.g. `http://localhost/api/ismm_online.php`
### 1b. Set up API for `Will these links block Tor user?`(isAT) ### 1b. Set up API for `Will these links block Tor user?`(isAT)

View File

@ -0,0 +1,34 @@
<?php
error_reporting(0);
header('HTTP/1.1 404 Not Found');
header('Access-Control-Allow-Origin: *');
header('Cache-Control: private, no-cache, no-store, max-age=0');
//
// { Example API for IsMM }
//
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
echo('OK');
exit();
}
header('Content-Type: application/json');
$fqdn = htmlspecialchars($_POST['f']);
if (!preg_match("/^([a-z0-9]{1})([a-z0-9.-]{0,254})\.([a-z]{2,50})$/", $fqdn)) {
echo('[false,false]');
exit();
}
$ck = curl_init();
curl_setopt($ck, CURLOPT_URL, 'https://karma.crimeflare.eu.org/api/is/cloudflare/');
curl_setopt($ck, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ck, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ck, CURLOPT_POST, true);
curl_setopt($ck, CURLOPT_POSTFIELDS, 'f=' . $fqdn);
curl_setopt($ck, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ck, CURLOPT_CONNECTTIMEOUT, 7);
curl_setopt($ck, CURLOPT_TIMEOUT, 13);
curl_setopt($ck, CURLOPT_USERAGENT, 'curl/ismm');
$got = curl_exec($ck);
if ($got === false || strpos($got, '[') !== 0) {
echo('[false,false]');
exit();
}
echo($got);