#!/usr/bin/perl

# FHTTP Kit by Xianur0
# Copyright (C) 2011 Oscar García López (http://hackingtelevision.blogspot.com) 
#  
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#   
#    xianur0.null@gmail.com
#    http://hackingtelevision.blogspot.com/

# xianur0.null@gmail.com
# If you delete the credits, I will fucking kill you.



# "Lasciate ogni speranza, voi ch’entrate". xD
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# Ready?
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# ...
# I warned you...

use lib("dic");
use dic;

sub included() {
	return 1;
}

use lib("test");
use test;

use Switch;
use IO::Socket::INET;
use if($mods{"IO::Socket::SSL"} == 1), IO::Socket::SSL;
use if($mods{"Gtk2"} == 1), Gtk2 => '-init';
use Socket;


use threads ('yield',
				'exit' => 'threads_only',
				'stringify');
use threads::shared;
# no warnings 'threads';

use Socket;
use POSIX;
use Switch;

if($mods{"Gtk2"} == 1) {
	@ARGV = ();
}


package main;

use if($mods{"Term::ANSIColor"} == 1),Term::ANSIColor;


our $red = (($mods{"Term::ANSIColor"} == 1) ? color("red") : "");
our $reset = (($mods{"Term::ANSIColor"} == 1) ? color("reset") : "");

sub red() {
	return $red;
}
sub mods {
	return $mods{$_[0]};
}
sub reset() {
	return $reset;
}
$idioma = mods("--lang");
sub fingerprinting() {
	use lib("parser");
	use parser;
	use lib("http");
	use http;
	use lib("fingerprint");
	use fingerprint;
	fingerprint->new();
}

sub stress() {
	use lib("control");
	use control;
	use lib("mn");
	use mn;
	mn->new();
}

sub analizar() {
	use lib("parser");
	use parser;
	use lib("http");
	use http;
	use lib("analizador");
	use analizador;
	analizador->new();
}

sub ofuscador() {
	use lib("parser");
	use parser;
	use lib("proxy");
	use proxy;
	proxy->new();
}
sub ping() {
	use lib("ping");
	use ping;
	use lib("tools");
	use tools;
	use lib("parser");
	use parser;
	use lib("http");
	use http;
	ping->new();
}


sub main() {
	my $ventana = Gtk2::Window->new('toplevel');
	$ventana->set_title("FHTTP - The HTTP Fu**er :D");
	$ventana->set_default_icon_from_file("icono.jpg");
	$ventana->set_border_width(5);
	$ventana->set_default_size(20, 20);
	$ventana->set_resizable(FALSE);
	$hbox = Gtk2::VBox->new(0, 0);
	$hbox->set_border_width(5);
	$imagen = Gtk2::Image->new_from_file("logo.png");
	$caja = Gtk2::HBox->new(0,0);
	$boton1 = Gtk2::Button->new('Fingerprint');
	$boton1->signal_connect('clicked' => sub { fingerprinting(); });
	$boton2 = Gtk2::Button->new('DoS Tool');
	$boton2->signal_connect('clicked' => sub { stress(); });
	$boton3 = Gtk2::Button->new(dic::titulos($idioma,0));
	$boton3->signal_connect('clicked' => sub { analizar() });
	$boton4 = Gtk2::Button->new('Proxy');
	$boton4->signal_connect('clicked' => sub { ofuscador(); });
	$boton5 = Gtk2::Button->new('HTPing');
	$boton5->signal_connect('clicked' => sub { ping(); });
	$hbox->pack_start($imagen, FALSE, FALSE, 2);
	$hbox->pack_start($boton1, FALSE, FALSE, 2);
	$hbox->pack_start($boton2, FALSE, FALSE, 2);
	$hbox->pack_start($boton4, FALSE, FALSE, 2);
	$hbox->pack_start($boton3, FALSE, FALSE, 2);
	$hbox->pack_start($boton5, FALSE, FALSE, 2);
	$hbox->show;
	$ventana->add($hbox);
	$ventana->show_all;
	Gtk2->main;
}
if($mods{"Gtk2"} == 1) {
	main();
} else {
	my $accion = $ARGV[0];
	switch($accion) {
		case '0' {
			fingerprinting();
		}
		case '1' {
			stress();
		}
		case '2' {
			analizar();
		}
		case '3' {
			ofuscador();
		}
		case '4' {
			ping();
		}
		default {
			die("Uso: fhttp.pl [modulo]\n0 - Fingerprint\n1 - DoS Tool\n2 - Analizador de metodos\n3 - Proxy Ofuscador\n4 - HTPing\n");
		}
	}
}
