#!/usr/bin/perl -w
use IO::Socket;
use Net::hostent;
$PORT = 6379;
$server = IO::Socket::INET->new( Proto => 'tcp',
LocalPort => $PORT,
Listen => 5,
Reuse => 1) or die "can't setup server" unless $server;
print "SERVER Waiting for client connection on port $PORT\n";
while ($client = $server->accept()) {
$client->autoflush(1);
while ( <$client> ) {
if (/quit|exit/i) { exit; }
else { print $_;}
}
close $client;
}
Showing posts with label tips-and-tricks. Show all posts
Showing posts with label tips-and-tricks. Show all posts
Tuesday, July 23, 2013
Perl TCP Listener
As a note to self, comes in handy whenever you're missing netcat:
Saturday, June 16, 2012
How to enable IP Forwarding in Mac OS X
Another note to self: how to enable IP forwarding in Mac OS X:
sudo sysctl -w net.inet.ip.forwarding=1(credit: Stack Exchange)
Thursday, May 24, 2012
How to disable ASLR in Linux
Quick note to self on how to disable ASLR (address space layout randomization) in Ubuntu Linux:
$ sudo sh -c "echo 0 > /proc/sys/kernel/randomize_va_space"
Wednesday, April 4, 2012
How to get a List of Installed JVMs on a Mac
I got this tip from a fellow worker:
$ /usr/libexec/java_home -VThis command will get you the list of installed Java Virtual Machines installed on your Mac OS X system.
Sunday, April 1, 2012
Inspecting the Process Environment Variables with GDB
While trying to solve the 4th level of the vortex wargame, I found it was necessary to learn how to inspect the location and content of the environment variables within the process memory.
GDB has built-in commands to inspect the process environment, see the GDB manual. You can either list all environment variables or a specific one (e.g. FOOBAR) using the following commands, which will output their values:
I also found these links to be useful:
GDB has built-in commands to inspect the process environment, see the GDB manual. You can either list all environment variables or a specific one (e.g. FOOBAR) using the following commands, which will output their values:
(gdb) show environment (gdb) show environment FOOBARIn order to locate the environment variables within the process memory, you can query the variable char** environ (see the libc reference and this entry on stack overflow):
(gdb) x/s *((char **)environ)This will print the location of the first environment variable and its representation as string. To print the next variables, simply add an offset to the variable:
(gdb) x/s *((char **)environ + 1)
I also found these links to be useful:
Friday, October 21, 2011
how to (quickly) perform a dns lookup without nslookup, dig, etc
Use perl for example:
$ perl -e 'use Socket; print inet_ntoa(inet_aton("example.com"));'
Subscribe to:
Posts (Atom)