<?php
/*
******************************
* Port Scanner *
* Main Window Class *
******************************
*/
if (!class_exists('gtk')) {
die("Please load the php-gtk2 module in your php.ini\r\n");
}
class PSWindow extends GTKWindow
{
private $vbxWrapper; // Wrapper. Will hold a number of GtkHBox's
/****
* GtkHBox for the Remote Address options (List, Save)
****/
private $hbxRemote;
private $cmbRemoteAddr;
private $chkRemoteSave;
/****
* GtkHBox for the Ports options (List, Save)
****/
private $hbxPorts;
private $cmbPorts;
private $chkPortsSave;
/****
* GtkHBox for the Options Line (Save, Print)
****/
private $hbxOptions;
private $chkSaveRes;
private $chkPrintRes;
/****
* GtkHBox for the Scan GtkButton
****/
private $hbxScan;
private $btnScan;
/****
* GtkHBox for results GtkLabel
****/
private $hbxResults;
private $lblResults;
/****
* Form Values
****/
private $remoteAddr;
private $ports;
public function __construct()
{
parent::__construct();
/****
* Set up the Window
*/
$this->set_title('Port Scanner');
$this->set_default_size(340,150);
$this->vbxWrapper = new GtkVBox();
/****
* Remote Address
****/
$this->hbxRemote = new GtkHBox();
/**********/
$this->cmbRemoteAddr = GtkComboBoxEntry::new_text();
$this->cmbRemoteAddr->append_text('127.0.0.1');
/**********/
$this->chkRemoteSave = new GtkCheckButton('Save This Address');
$this->chkRemoteSave->set_inconsistent(true);
/**********/
$this->hbxRemote->pack_start($this->cmbRemoteAddr, false, false, 5);
$this->hbxRemote->pack_start($this->chkRemoteSave, false, false, 5);
/**********/
$this->vbxWrapper->pack_start($this->hbxRemote, true, true, 5);
/****
* Ports
****/
$this->hbxPorts = new GtkHBox();
/**********/
$this->cmbPorts = GtkComboBoxEntry::new_text();
$this->cmbPorts->append_text('21,23,25,79,80,110,135,137,138,139,143,443,445,1433,3306,3389');
/**********/
$this->chkPortsSave = new GtkCheckButton('Save This list');
/**********/
$this->hbxPorts->pack_start($this->cmbPorts, false, false, 5);
$this->hbxPorts->pack_start($this->chkPortsSave, false, false, 5);
/**********/
$this->vbxWrapper->pack_start($this->hbxPorts, true, true, 5);
/****
* Options
****/
$this->hbxOptions = new GtkHBox();
/**********/
$this->chkSaveRes = new GtkCheckButton('Save Results');
/**********/
$this->chkPrintRes = new GtkCheckButton('Print Results');
$this->chkPrintRes->set_active(true);
/**********/
$this->hbxOptions->pack_start(new GtkLabel(), true);
$this->hbxOptions->pack_start($this->chkSaveRes, false, false, 10);
$this->hbxOptions->pack_start($this->chkPrintRes, false, false, 10);
$this->hbxOptions->pack_start(new GtkLabel(), true);
/**********/
$this->vbxWrapper->pack_start($this->hbxOptions,true, true, 5);
/****
* Scan
****/
$this->hbxScan = new GtkHBox();
/**********/
$this->btnScan = new GtkButton('Scan!');
$this->btnScan->connect('clicked', array('PSWindow', 'scan'));
/**********/
$this->hbxScan->pack_start(new GtkLabel(), true);
$this->hbxScan->pack_start($this->btnScan, false, false, 10);
$this->hbxScan->pack_start(new GtkLabel(), true);
/**********/
$this->vbxWrapper->pack_start($this->hbxScan, true, false, 5);
/****
* Results
****/
$this->hbxResults = new GtkHBox();
/**********/
$this->lblResults = new GtkLabel();
/**********/
$this->hbxResults->pack_start($this->lblResults, true, true, 10);
/**********/
$this->vbxWrapper->pack_start($this->hbxResults, true, true, 10);
$this->add($this->vbxWrapper);
}
public function scan(GtkButton $button)
{
$this->remoteAddr = $this->cmbRemoteAddr->get_active_text();
}
}
$wnd = new PSWindow();
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
$wnd->show_all();
Gtk::main();
?>