Ubuntu – Which Process is Using a port? 1- Find what application/process is using the pro, type: sudo netstat -lpn |grep :8080 and press Enter. You will get an output similar to this one tcp6 0 0 :::8080 :::* LISTEN 6782/java 2- I have got the process Id, which is 6782, now this is the […]
Heart Bleed – Exploit Example Code If you need to test your server for the vulnerability, here is a simple Python script… [python] #!/usr/bin/python import sys import struct import socket import time import select import re from optparse import OptionParser options = OptionParser(usage=’%prog server [options]’, description=’Test for SSL heartbeat vulnerability (CVE-2014-0160)’) options.add_option(‘-p’, ‘–port’, type=’int’, default=443, […]
In case you haven’t heard, a critical bug in the widely used OpenSSL library has been disclosed this week. http://www.bbc.co.uk/news/technology-26971363 Despite the cool name and vector logo, Heartbleed is one of the scariest security bugs to hit the Internet in a long time. I was able to query my own server to reveal memory […]
Perl – Compare Array Contents when length is identical and order matches Comparing arrays side by side. Do they match or dont they? @a=(1,0,1,0,0); @b=(0,0,1,0,0); NO! @arr1=(0,1,1,1,1,1,0,1); @arr2=(0,1,1,1,1,1,0,1); use Algorithm::Diff qw( LCS_length); my $arr_count1 = @arr1; my $arr_count2 = @arr2; if($arr_count1 != $arr_count2) { print “NOMATCH\n”; ## NO MATCH } else { $count = LCS_length […]
Perl – Code Execution Time with accuracy – Time::HiRes How long does it take to execute some code? use Time::HiRes qw( time ); my $start = time(); // Code goes here sleep 10; my $end = time(); print “SPRINTF: “; printf(“%.6f\n”, $end – $start);
PERL – Bitwise OR XOR an array [perl] my @data= (“80″,”80″,”7B”,”30″,”32″,”30″,”38″,”31″,”46″,”30″,”39″); my $chk; foreach my $point(@data) { $chk = $chk^$point; ## XOR each array } $chk = hex($chk)|hex(“80”); ## OR the result value my $chk_hex=sprintf(“%x”,$chk); ## convert result to hex print “$chk = $chk_hex\n”; ## display both results side by side [/perl]
SFTP Only for a user – Debian Add the user info the sshd_config file in /etc/ssh/sshd_config Ensure the line is uncommented; Subsystem sftp /usr/lib/openssh/sftp-server Match User userbob ForceCommand internal-sftp ChrootDirectory /home/userbob X11Forwarding no AllowTcpForwarding no Ensure the home directory is not group writeable. It should be 755. /etc/init.d/ssh restart service ssh restart Test the […]
Perl DBH get last id SIMPLES with DBH Mysql my $sth = $dbh->do(“$SQL”); my $id = $dbh->{‘mysql_insertid’};
Perl Hex to Binary to Decimal Conversions Dec to Hex Use function sprintf(“%x”, DECNUMBER) or sprintf(“%X”, DECNUMBER) for hexadecimal numbers with capital letters. $decvalue = 200; $hexvalue = sprintf(“%x”, $decvalue); ## gives c8 $hexvalue = sprintf(“%X”, $decvalue); ## gives C8 Dec to Oct Use sprintf(“%o”, DECNUMBER ) $decvalue = 200; $octval = sprintf( “%o”, $decvalue […]
PERL XOR 2 HEx values Need to XOR to hex values… try this. $NEW_VAL = hex(80) ^ hex(9D);