NiX API is a powerful anti-proxy, anti-fraud, and IP reputation lookup API. It uses the NiX database at cli.nixapi.com to determine IP country/region/city, data center details, satellite provider details, open proxy details, and Tor network association.
474102596a87d21818c553be365a5aee27299455bc52719a27f2ca79bcfa0979
#!/usr/local/bin/php
<?php
/*---------------------------------------------------------------------
/ Copyright (c) 2011 - NiX - http://nixapi.com/ - All Rights Reserved /
---------------------------------------------------------------------*/
/*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and to distribute modified versions of this software for any
* purpose, provided that the above copyright notice and the following
* two paragraphs appear in all copies of this software.
*
* In no event shall NiX LLC or the NiX Development Group be liable
* to any party for direct, indirect, special, incidental, or consequential
* damages arising out of the use of this software and its documentation,
* even if NiX LLC and the NiX Development Group have been advised of
* the possibility of such damage.
*
* NiX LLC and the NiX Development Group specifically disclaim any
* warranties, including, but not limited to, the implied warranties of
* merchantability and fitness for a particular purpose. The software
* provided hereunder is on an "as is" basis, and NiX LLC and the
* NiX Development Group have no obligation to provide maintenance,
* support, updates, enhancements, or modifications.
*/
/*---------------------------------------------------------------------
/ INSTALLATION & USAGE /
---------------------------------------------------------------------*/
/*
1) cp nixapi /usr/local/sbin/
2) chmod 755 /usr/local/sbin/nixapi
Usage: nixapi 127.0.0.1
*/
error_reporting(E_ALL ^ E_NOTICE);
$ipaddr = trim($argv[1]);
if ($argc < 2 || !ip($ipaddr)) { die ("[-] Please enter a valid IPv4 address.\n"); }
$hostname = gethostbyaddr($ipaddr);
/*
Leave variables below empty if you are not using a proxy to query the API. Paste the proxy in proxy format 127.0.0.1:1234
*/
$api_proxy = "";
// Proxy type: HTTP or SOCKS4 or SOCKS5
$api_proxytype = "";
if ($response = nix_api()) {
$country = str_between($response, "<country>", "</country>");
$abbr = str_between($response, "<abbr>", "</abbr>");
$region = str_between($response, "<region>", "</region>");
$city = str_between($response, "<city>", "</city>");
$open_proxy = str_between($response, "<opd>", "</opd>");
$tor = str_between($response, "<tor>", "</tor>");
$data_center = str_between($response, "<dc>", "</dc>");
$satellite_provider = str_between($response, "<sp>", "</sp>");
$api_codes = str_between($response, "<codes>", "</codes>");
$tor_nodes = str_between($response, "<tornodes>", "</tornodes>");
$active_proxies = str_between($response, "<activeproxies>", "</activeproxies>");
$total_proxies = str_between($response, "<totalproxies>", "</totalproxies>");
$hosting_providers = str_between($response, "<hostingproviders>", "</hostingproviders>");
$hosting_subnets = str_between($response, "<hostingsubnets>", "</hostingsubnets>");
$satellite_providers = str_between($response, "<satelliteproviders>", "</satelliteproviders>");
$satellite_subnets = str_between($response, "<satellitesubnets>", "</satellitesubnets>");
echo "
|N|/-------------------------------------------------------------------------------------\|A|
|i| NiX API CLI - (c) http://nixapi.com/ |P|
|X|\-------------------------------------------------------------------------------------/|I|
CURRENTLY KEEPS RECORDS OF:
[+] $hosting_providers hosting provider IP's in $hosting_subnets subnets.
[+] $satellite_providers satellite provider IP's in $satellite_subnets subnets.
[+] $total_proxies open proxies in the past two week period where $active_proxies proxies
worked in the past 12 hours.
[+] $tor_nodes Tor nodes
IPv4: $ipaddr Hostname: $hostname
Country long: $country Country abbr.: $abbr Region: $region City: $city
Data center: $data_center
Satellite provider: $satellite_provider
Open proxy database: $open_proxy
Tor network: $tor
API codes: $api_codes - More information: http://nixapi.com/documentation
Open Proxy Scan is disabled in CLI mode. Use http://nixapi.com/ip-reputation-lookup
IP Reputation Lookup is disabled in CLI mode. Use http://nixapi.com/ip-reputation-lookup
";
} else {
die("[-] An error has occurred. Please try again.\n");
}
/*---------------------------------------------------------------------
/ DO NOT EDIT ANYTHING BELOW OR THE QUERY WILL FAIL /
---------------------------------------------------------------------*/
function str_between($string, $start, $end) {
$string = " ".$string;
$ini = strpos($string, $start);
if ($ini == 0) {
return "";
}
$ini += strlen($start);
$len = strpos($string, $end, $ini) - $ini;
return substr($string, $ini, $len);
}
function nix_api () {
global $ipaddr,$api_proxy,$api_proxytype;
$proxy_regex = '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5})';
if (!function_exists('curl_init')) {
die("[-] Error: Curl is not enabled.\n");
}
// Load-balanced API server-pool
$nixapi = "http://cli.nixapi.com/";
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => 1,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_ENCODING => "",
CURLOPT_USERAGENT => "NiX API CLI",
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 4,
CURLOPT_TIMEOUT => 60,
CURLOPT_MAXREDIRS => 1,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => false,
CURL_HTTP_VERSION_1_1 => true,
CURLOPT_VERBOSE => 0,
CURLOPT_POSTFIELDS => "ipaddr=$ipaddr"
);
$ch = curl_init($nixapi);
curl_setopt_array($ch,$options);
if (!empty($proxy)) {
switch ($proxytype) {
case "HTTP": curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); break;
case "SOCKS4": curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); break;
case "SOCKS5": curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); break;
default: die("[-] Error: Invalid proxy type.\n");
}
if (preg_match("$proxy_regex", $proxy)) {
curl_setopt($ch, CURLOPT_PROXY, $proxy);
} else {
die("[-] Error: Invalid proxy.\n");
}
}
// Query NiX API
$response = curl_exec($ch);
$errno = curl_errno($ch);
$errmsg = curl_error($ch) ;
$info = curl_getinfo($ch);
curl_close($ch);
if ($errno == "0" && $info['http_code'] == "200") {
return $response;
} else {
return false;
}
}
function ip($ip = '') {
if (preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $ip)) {
$parts = explode(".", $ip);
foreach ($parts as $ip_parts) {
if (intval($ip_parts) > 255 || intval($ip_parts) < 0) {
return false;
}
}
return true;
} else {
return false;
}
}
?>