Archive for April, 2009

TCP Connect Port Scanner Source Code in C with Winsock

TCP connect() scanning is the most basic form of TCP scanning. The program performs a connect() command on those ports of the target machine which are to be checked. If the port is open then the connect() command will succeed and a connection will be established. If the port is closed the connect() function would [...]

TCP Connect Port Scanner with Linux Sockets (BSD)

TCP Connect Port Scanner works by trying to establish a connection with every port that is being scanned. If a connectio is established then the port is open otherwise closed.
The steps are simple :

PHP parse text and change urls into links

Regex can be used to convert all urls in a plain text into links i.e. with anchor tags.
Code :
function parse_links($str)
{
$str = str_replace(’www.’, ‘http://www.’, $str);
$str = preg_replace(’|http://([a-zA-Z0-9-\./]+)|’, ‘<a href="http://$1">$1</a>’, $str);
$str = preg_replace(’/(([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6})/’, ‘<a href="mailto:$1">$1</a>’, $str);
return $str;
}
?>

C Packet Sniffer Code with Libpcap and Linux Sockets (BSD)

Libpcap is a packe capture library which can be used to sniff packets or network traffic over a network interface. Pcap Documentation gives a description of the methods and data structures available in the libpcap library.

Packet Sniffer Code in C using Linux Sockets (BSD)

To code a sniffer in C (Linux) the steps would be :
1. Create a Raw Socket.
2. Put it in a recvfrom loop.
A raw socket when put in recvfrom receives all incoming packets. The following code shows an example of such a sniffer. Note that it sniffs only incoming packets. For sniffing all traffic on a [...]

Send mail with PHP

The mail function of php can be used to send mails.
E.g.

$to = ‘recipient@example.com’;
$subject = ‘Hello This is the Subject’;
$body = ‘Hello This is the Body’;
if (mail($to, $subject, $body))
{
echo ‘Message Delivered’;
}
else
{
echo ‘Message delivery failed’;
}

Javascript Image Cropper with Mootools and PHP

MooCrop is a library which can be used to create a cropping interface in your webpage. With this library after a crop region is selected a php script can be called to crop the image on serverside. The moocrop interface provides four values that is the width , height , left and top of the [...]

Konqueror Dolphin not accessing Windows FTP Server

Hmmm, so it looks like that konqueror or dolphin wont access a windows ftp server properly whereas its absolutely fine and fast with linux ftp servers. One reason for this could be the NTLM authentication that windows ftp servers use.

Slow Internet on Ubuntu when using a switch

As usual internet was fast on ubuntu as it used to be till I needed to plug more PCs into the adsl route lying nearby. After connecting all computers and the adsl router to a switch I noticed that on one of the PC (Ubuntu 8.04) internet became really slow. Rest of the 2 PCs [...]