1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#!/usr/bin/perl -w
# This Irssi script automatically check incoming http/https links
# and replace it to archive one if it is MITMed.
#---------------------------------------------------------------------
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = "20190501";
%IRSSI = (
authors => "Anonymous",
contact => 'nobody@cloudflare-tor.nab',
name => "irssi_cf_alturl.pl",
description => "Cloudflare URL replacer",
license => "WTFPL",
changed => "$VERSION"
);
use Irssi;
use Irssi::Irc;
use LWP::Simple;
use LWP::UserAgent;
my ( $min_url_length, $send_to_channel, $debug, $channel_list );
sub setuphandler {
$send_to_channel = 1;
$channel_list = '';
my $old_min_url_length = $min_url_length;
$min_url_length = 0;
my $old_debug = $debug;
$debug = 0;
}
sub GotUrl {
my ( $server, $data, $nick, $addr, $target ) = @_;
if ( !$server || !$server->{connected} ) {
Irssi::print("Not connected to server");
return;
}
$data =~ s/^\s+//;
$data =~ s/\s+$//;
my @urls = ();
my ( $url, $a, $return, $char, $ch, $result, $choice ) = "";
my $same = 0;
my $sitewas = "t";
my @chars = ();
return unless ( ( $data =~ /\bhttp\:/ ) || ( $data =~ /\bhttps\:/ ) );
deb("$target triggered GotUrl() with url: $data");
foreach ( split( /\s/, $data ) ) {
if ( ( $_ =~ /^http\:/ ) || ( $_ =~ /^https\:/ ) ) {
foreach $a (@urls) {
if ( $_ eq $a ) {
$same = 1;
next;
}
}
if ( $same == 0 ) {
$same = 0;
push( @urls, $_ );
}
}
}
foreach (@urls) {
@chars = split( //, $_ );
foreach $char (@chars) {
if ( $char !~ /[A-Za-z0-9]/ ) {
$ch = sprintf( "%%%02x", ord($char) );
$result .= $ch;
}
else {
$result .= $char;
}
}
$choice = 'searxesmitmdb';
deb("mitmtest(\$server, $target, $result)");
mitmtest( $server, $target, $result );
}
return;
}
sub mitmtest {
my ( $server, $chan, $longurl ) = @_;
my ($fqdn) = $longurl =~ m!(https?://[^:/]+)!;
my ( $junk, $fqdn ) = split( /\/\//, $fqdn, 2 );
my $url = 'https://searxes.danwin1210.me/collab/open/ismitm.php?f=' . $fqdn;
deb("getting url:($url)");
my $browser = LWP::UserAgent->new;
$browser->agent("cloudflare cflare_alt.pl");
my $response = $browser->get($url);
my $scanned_url = $response->content;
## if the array[1] is true => it is MITM
if ( $scanned_url == '[true,true]' ) {
$scanned_url = 'https://web.archive.org/web/' . $longurl;
}
else {
$scanned_url = $longurl;
}
if ( $response->is_success ) {
if ( $send_to_channel == 1 ) {
$server->command("msg $chan $scanned_url");
}
else {
$server->print( "$chan", "$scanned_url", MSGLEVEL_CLIENTCRAP );
}
}
else {
deb("ERROR: service is down or not pingable");
}
}
sub deb($) {
Irssi::print(shift) if ( $debug == 1 );
}
setuphandler();
Irssi::signal_add( "setup changed", "setuphandler" );
Irssi::signal_add_last( "message public", "GotUrl" );
Irssi::signal_add_last( "ctcp action", "GotUrl" );
|