Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Implemented HTML templates
Browse files Browse the repository at this point in the history
  • Loading branch information
TETYYS committed Aug 13, 2015
1 parent a60e7ca commit 697a47a
Show file tree
Hide file tree
Showing 274 changed files with 28,833 additions and 57 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ project (LIVEPROXIES)

set (CMAKE_C_FLAGS "--std=gnu99 -pthread ${CMAKE_C_FLAGS}")

add_executable(LiveProxies Base64.c Global.c Harvester.c Interface.c IPv6Map.c LiveProxies.c Logger.c ProxyLists.c ProxyRemove.c ProxyRequest.c Server.c PBKDF2.c SingleCheck.c)
add_executable(LiveProxies Base64.c Global.c Harvester.c Interface.c IPv6Map.c LiveProxies.c Logger.c ProxyLists.c ProxyRemove.c ProxyRequest.c Server.c PBKDF2.c SingleCheck.c HtmlTemplate.c)
target_link_libraries(LiveProxies event GeoIP crypto ssl python2.7 pcre config m util)
2 changes: 1 addition & 1 deletion Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "IPv6Map.h"
#include <stddef.h>

#define VERSION "0.5.1"
#define VERSION "0.6.0"
#define CALLBACK
#define OUT
#define MEM_OUT
Expand Down
49 changes: 26 additions & 23 deletions Interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,27 +815,32 @@ static void InterfaceRawRecheckStage2(UNCHECKED_PROXY *UProxy)

PROXY *proxy = UProxy->associatedProxy;

struct evbuffer *body = evbuffer_new(); {
char anon;
if (proxy->anonymity == ANONYMITY_TRANSPARENT)
anon = 't';
else if (proxy->anonymity == ANONYMITY_ANONYMOUS)
anon = 'a';
else if (proxy->anonymity == ANONYMITY_MAX)
anon = 'm';
else
anon = 'n';

char *uid = GenerateUidForProxy(proxy); {
char *liveSinceTime = FormatTime(proxy->liveSinceMs); {
char *lastCheckedTime = FormatTime(proxy->lastCheckedMs); {
evbuffer_add_printf(body, "{ \"anonymity\": '%c', \"httpTimeoutMs\": %d, \"timeoutMs\": %d, \"liveSince\": \"%s\", \"lastChecked\": \"%s\", \"retries\": %d, \"successfulChecks\": %d, \"failedChecks\": %d, \"uid\": \"%s\" }",
anon, proxy->httpTimeoutMs, proxy->timeoutMs, liveSinceTime, lastCheckedTime, proxy->retries, proxy->successfulChecks, proxy->failedChecks, uid);
} free(lastCheckedTime);
} free(liveSinceTime);
} free(uid);
bufferevent_write_buffer(buffEvent, body);
} evbuffer_free(body);
struct evbuffer *http = evbuffer_new();
struct evbuffer *body = evbuffer_new();
char anon;
if (proxy->anonymity == ANONYMITY_TRANSPARENT)
anon = 't';
else if (proxy->anonymity == ANONYMITY_ANONYMOUS)
anon = 'a';
else if (proxy->anonymity == ANONYMITY_MAX)
anon = 'm';
else
anon = 'n';

char *uid = GenerateUidForProxy(proxy); {
char *liveSinceTime = FormatTime(proxy->liveSinceMs); {
char *lastCheckedTime = FormatTime(proxy->lastCheckedMs); {
evbuffer_add_printf(body, "{ \"anonymity\": \"%c\", \"httpTimeoutMs\": %d, \"timeoutMs\": %d, \"liveSince\": \"%s\", \"lastChecked\": \"%s\", \"retries\": %d, \"successfulChecks\": %d, \"failedChecks\": %d, \"uid\": \"%s\" }",
anon, proxy->httpTimeoutMs, proxy->timeoutMs, liveSinceTime, lastCheckedTime, proxy->retries, proxy->successfulChecks, proxy->failedChecks, uid);
} free(lastCheckedTime);
} free(liveSinceTime);
} free(uid);
evbuffer_add_printf(http, "%d", evbuffer_get_length(body) * sizeof(char)); // To Content-Length
evbuffer_add_reference(http, "\r\nContent-Type: text/html\r\n\r\n", 29 * sizeof(char), NULL, NULL);
bufferevent_write_buffer(buffEvent, http);
bufferevent_write_buffer(buffEvent, body);
evbuffer_free(http);
evbuffer_free(body);

bufferevent_flush(buffEvent, EV_WRITE, BEV_FINISHED);
bufferevent_free(buffEvent);
Expand Down Expand Up @@ -871,8 +876,6 @@ void InterfaceRawRecheck(struct bufferevent *BuffEvent, char *Buff)
}

Recheck(proxy, InterfaceRawRecheckStage2, BuffEvent);
evbuffer_add_printf(headers, "%d", 1 * sizeof(char)); // To Content-Length
evbuffer_add_reference(headers, "\r\nContent-Type: text/html\r\n\r\n", 29 * sizeof(char), NULL, NULL);

bufferevent_write_buffer(BuffEvent, headers);
evbuffer_free(headers);
Expand Down
16 changes: 3 additions & 13 deletions LiveProxies.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ int main(int argc, char** argv)
//event_enable_debug_logging(EVENT_DBG_ALL);
#endif

if (access("/etc/liveproxies/passwd.conf", F_OK) == -1 || access("./passwd.conf", F_OK) == -1)
Log(LOG_LEVEL_WARNING, "No credentials present for interface pages. Access blocked by default.");

evthread_use_pthreads();

AuthWebList = NULL;
Expand Down Expand Up @@ -322,19 +325,6 @@ int main(int argc, char** argv)
"User-Agent: LiveProxies Proxy Checker %s (tetyys.com)\r\n"
"\r\n", "%s", "%s", VERSION);

// RequestHeaders = evhtp_headers_new();

// evhtp_headers_add_header(RequestHeaders, evhtp_header_new("Connection", "Close", 0, 0));
// evhtp_headers_add_header(RequestHeaders, evhtp_header_new("Cache-Control", "max-age=0", 0, 0));
// evhtp_headers_add_header(RequestHeaders, evhtp_header_new("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", 0, 0));
// char *ua = malloc(39 + strlen(VERSION) + 1); {
// sprintf(ua, "LiveProxies Proxy Checker %s (tetyys.com)", VERSION);
// evhtp_headers_add_header(RequestHeaders, evhtp_header_new("User-Agent", ua, 0, 1));
// } free(ua);
// evhtp_headers_add_header(RequestHeaders, evhtp_header_new("DNT", "1", 0, 0));
// evhtp_headers_add_header(RequestHeaders, evhtp_header_new("Accept-Encoding", "gzip, deflate, sdch", 0, 0));
// evhtp_headers_add_header(RequestHeaders, evhtp_header_new("Accept-Language", "en-US,en;q=0.8", 0, 0));

const char *pcreError;
int pcreErrorOffset;
const char *err;
Expand Down
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LiveProxies
===================
Latest Version: **0.5.1** (pre-release)
Latest Version: **0.6.0** (pre-release)

LiveProxies is a [high-performance](#performance) asynchronous proxy checker.

Expand All @@ -11,10 +11,20 @@ LiveProxies is a [high-performance](#performance) asynchronous proxy checker.
- - When proxy modifies or adds any kind of headers - **anonymous**
- - When proxy headers match request headers - **max**
- Doesn't require any external web servers for its interface and internal proxy checking page
- Supports:
- - HTTP
- - HTTPS
- - SOCKS4
- - SOCKS4A
- - SOCKS5
- - SOCKS4 -> SSL
- - SOCKS4A -> SSL
- - SOCKS5 -> SSL
- - SOCKS5 UDP association
- ...

## Get it running
If you still haven't installed depencencies:
If you still haven't installed [depencencies](#dependencies):
```
apt-get install libevent-dev python2.7-dev libssl-dev libgeoip-dev libpcre3-dev libconfig-dev
```
Expand All @@ -26,9 +36,10 @@ make
#### Installation:
```
mkdir /etc/liveproxies
mkdir /etc/liveproxies/scripts
mv ./docs/liveproxies.conf /etc/liveproxies.conf
cp -R config/* /etc/liveproxies
nano /etc/liveproxies.conf # Modify configuration here
mkdir /usr/local/share/GeoIP
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
Expand All @@ -40,16 +51,13 @@ mv GeoIPv6.dat /usr/local/share/GeoIP/
#### Usage:

Now you probably would want to add scraping scripts to `/etc/liveproxies/scripts`.

See `BlogspotGeneric.py` for example script. **NOTE:** All blogspot websites are different, so script doesn't always match with blog HTML.

After running, you can see your proxy lists at
- [ip]:[port]/iface - **Valid proxy list**
- [ip]:[port]/ifaceu - **Currently unchecked proxy list**
After running, you can access interface at [ip]:[server port]/

See [Auth](docs/auth.md) for preparing users for interface pages
See [Auth](docs/auth.md) for preparing users for interface. **Access to interface is blocked by default if no users are present.**

## Dependencies
## Dependencies <a name="dependencies"></a>
- libevent >= 2.1.5-beta
- python >= 2.7
- [Maxmind's GeoIP]
Expand All @@ -64,21 +72,16 @@ The program is currently in its very early stages, so any help is appreciated. S
Currently, program doesn't slow down at all at 7000 simultaneous proxy checks, but has memory problems. 85 MB for 7000 simultaneous proxy checks seems high.

## TODO
- Implement full proxy check
- Provide more information on interface pages, fix formatting
- - Spamhaus ZEN
- - Reverse DNS
- Provide more services in full proxy check
- - ~Spamhaus ZEN~
- - ~Reverse DNS~
- - StopForumSpam API
- - Project Honey Pot Http:BL + access key
- - Test proxy against legit pages
- - ...
- Provide more interactivity on interface pages
- Interface pages needs design **ASAP**! (seriously, they look hideous)
- Implement checked proxy checking.

- ...


[Maxmind's GeoIP]:https://github.com/maxmind/geoip-api-c/
[libevhtp]:https://github.com/TETYYS/libevhtp
[original libevhtp]:https://github.com/ellzey/libevhtp
[Maxmind's GeoIP]:https://github.com/maxmind/geoip-api-c/
132 changes: 132 additions & 0 deletions config/html/check.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<div id="page-wrapper">
<script>
$(document).ready(function() {
var uid = '{T_CHECK_UID}';
$.ajax({
url: '/check?uid=' + uid,
dataType: 'json'
}).done(function(data) {
var anon = $('#anonymity');
switch (data.anonymity) {
case "t": // Transparent
anon.addClass("alert-danger");
$('#anonymityText').text("Transparent");
$('#anonymityIcon').addClass("fa-close");
break;
case "a": // Anonymous
anon.addClass("alert-warning");
$('#anonymityText').text("Anonymous");
$('#anonymityIcon').addClass("fa-exclamation");
break;
case "m": // Max
anon.addClass("alert-success");
$('#anonymityText').text("Max");
$('#anonymityIcon').addClass("fa-check");
break;
case "n": // None (in case of UDP)
anon.addClass("alert-info");
$('#anonymityText').text("N/A");
$('#anonymityIcon').addClass("fa-question");
break;
}

anon.show("slow");

$('#liveSince').text(data.liveSince);
$('#lastChecked').text(data.lastChecked);
$('#timeoutMs').text(data.timeoutMs);
$('#httpTimeoutMs').text(data.httpTimeoutMs);
$('#successfulChecks').text(data.successfulChecks);
$('#retries').text(data.retries);
});
$.ajax({
url: '/zen?uid=' + uid
}).done(function(data) {
var zen = $('#zen');
var zenImg = $('#zenImg');

switch (data) {
case "sbl":
zen.addClass("alert-danger");
zenImg.attr("src", "/spamhaus/sbl.gif");
zenImg.attr("alt", "Spamhaus block list");
break;
case "css":
zen.addClass("alert-danger");
zenImg.attr("src", "/spamhaus/css.gif");
zenImg.attr("alt", "Component of the SBL");
break;
case "xbl":
zen.addClass("alert-danger");
zenImg.attr("src", "/spamhaus/xbl.gif");
zenImg.attr("alt", "Exploits block list");
break;
case "pbl":
zen.addClass("alert-warning");
zenImg.attr("src", "/spamhaus/pbl.gif");
zenImg.attr("alt", "Policy block list");
break;
case "cln":
zen.addClass("alert-success");
$('#zenImgWrap').html("<i class=\"fa fa-check\"></i>");
break;
}

zen.show("slow");
});
$.ajax({
url: '/rdns?uid=' + uid
}).done(function(data) {
$('#rdnsText').text(data);
$('#rdns').show("slow");
});
});
</script>
<div class="container-fluid">
<!-- Page Heading -->
<div class="row" style="padding-bottom:15px">
<div class="row">
<div class="col-lg-3">
<i class="fa fa-clock-o"></i> Live since <span id="liveSince">{T_CHECK_LIVE_SINCE}</span>
</div>
<div class="col-lg-3">
<i class="fa fa-clock-o"></i> Last checked <span id="lastChecked">{T_CHECK_LAST_CHECKED}</span>
</div>
<div class="col-lg-3">
<i class="fa fa-clock-o"></i> Last connect timeout: <span id="timeoutMs">{T_CHECK_CONNECT_TIMEOUT}</span> ms
</div>
<div class="col-lg-3">
<i class="fa fa-clock-o"></i> Last HTTP/S timeout: <span id="httpTimeoutMs">{T_CHECK_HTTP_S_TIMEOUT}</span> ms
</div>
</div>
<div class="col-lg-10">
<h2>Checking {T_CHECK_IP}:{T_CHECK_PORT} ({T_CHECK_TYPE})...</h2>
<div style="position:absolute;bottom:-20px">
<i class="fa fa-check"></i> <span id="successfulChecks">{T_CHECK_SUCCESSFUL_CHECKS}</span> / <i class="fa fa-close"></i> <span id="failedChecks">{T_CHECK_FAILED_CHECKS}</span> / <i class="fa fa-refresh"></i> <span id="failedChecks">{T_CHECK_RETRIES}</span>
</div>
</div>
<div class="col-lg-2 text-right">
<img style="height:110px" src="/flags/{T_CHECK_COUNTRY_LOWER}.svg">
</div>
</div>
<div class="row">
<div class="alert fade in col-lg-12 text-center" id="anonymity" style="padding: 0; display: none">
<h2 style="position:absolute;top: 5px;right: 5px;margin:0"><i class="fa fa-user-secret"></i></h2>
<h3 style="margin:10px"><i id="anonymityIcon" class="fa"></i> <span id="anonymityText"></span></h3>
</div>
</div>
<div class="row">
<div class="alert fade in col-lg-12 text-center" id="zen" style="padding: 0; display: none">
<img style="position: absolute; right: 5px; top: 5px;" src="//www.spamhaus.org/images/zen_badge3.gif">
<h3 id="zenImgWrap"><img id="zenImg"></h3>
</div>
</div>
<div class="row">
<div class="alert alert-info fade in col-lg-12 text-center" id="rdns" style="padding: 0; display: none">
<h3 style="position:absolute;top: 5px;right: 5px;margin:0">Reverse DNS</h3>
<h3 style="margin:10px" id="rdnsText"></h3>
</div>
</div>
</div>
<!-- /.container-fluid -->
</div>
Loading

0 comments on commit 697a47a

Please sign in to comment.