Showing posts with label robot. Show all posts
Showing posts with label robot. Show all posts

Saturday, July 4, 2009

Alpha-Rex, Ruby-nxt fail, out takes of my robot with a microkorg voice



***EDIT Appparently I built him wrong as at LEAST 200 hundred people have let me know END EDIT July 12th 2009***

Alpha Rex is a horrible design, but only partially my fault. He was designed by lego and is the flagship robot for the nxt design series. I had to improvise a lot of the building because I just didn't have the parts. And yeah I may have lost a lego or two, but not that many honestly for the amount of improvisation involved. On top of that I could tell just by the design that his "legs" were just a hack. He doesn't really walk, in fact much more similar to spike, he "land swims". With the program I wrote for him I pretty much just wanted to get him to walk by alternating the motors. Oh woah is me. Just watch the video to see what ensuses. So just wanting a robot platform to put intelligence into I sit and I wait and I hope, eyes gazing towards the Nao robots.

Sunday, March 22, 2009

ARP sniffer in perl, killing wireless intruders...literaly

caveat: This was written on OS X but I believe it will work just fine if you put your MAC addresses and replace the name of my interface with your interface. Make sure you have root/administrator privelages when you launch the program, IE sudo/no uac.

THANK YOU PAUL MILLER. For making the perl module Net::Pcap::Easy. I made this arp sniffer, which really is to say I just pasted some of the Net::Pcap::Easy documentation down. But anyway I am going put this code in my robot's code, so that, in the event of a wireless intruder, he will find them...and kill them.


The Technical stuff...

So why arp, why not just do a ping sweep or query a udp port or something? Well port's can be blocked, and ping(ICMP) can also be blocked. ARP is required for communication and is broadcast. I could have used dhcp but an intruder could statically set an ip address.


use Net::Pcap::Easy;
my @internalMac = qw( 0023329dcdf5 0023120914f9 );
# all arguments to new are optoinal
my $npe = Net::Pcap::Easy->new(
dev => "en0",
packets_per_loop => 10,
bytes_to_capture => 1024,
timeout_in_ms => 0, # 0ms means forever
promiscuous => 0, # true or false

default_callback => sub {
my ($npe, $ether, $po, $spo) = @_;

if( $po ) {
if( $po->isa("NetPacket::ARP") ) {
print "ARP packet: $po->{sha} -> $po->{tha}\n";
my $element = $po->{sha};
print $element;
if (grep {$_ eq $element} @internalMac) {
print " ARP address is yours"."\n" ;
}else{
print " intruder!\n";
}
}


}
}
);
1 while $npe->loop;



Oh and if your curious the output kind of looks like this:




ARP packet: 0023329dcdf5 -> 000000000000
0023329dcdf5 ARP address is yours
ARP packet: 001c10f48be6 -> 0023329dcdf5
001c10f48be6 intruder!
ARP packet: 0023120914f9 -> 000000000000
0023120914f9 ARP address is yours
ARP packet: 0023120914f9 -> 000000000000
0023120914f9 ARP address is yours
ARP packet: 0023120914f9 -> 000000000000
0023120914f9 ARP address is yours
ARP packet: 0023120914f9 -> 000000000000
0023120914f9 ARP address is yours
ARP packet: 0023120914f9 -> 000000000000
0023120914f9 ARP address is yours
ARP packet: 0023120914f9 -> 000000000000
0023120914f9 ARP address is yours
ARP packet: 0023329dcdf5 -> 000000000000
0023329dcdf5 ARP address is yours
ARP packet: 001c10f48be6 -> 0023329dcdf5
001c10f48be6 intruder!
ARP packet: 0023120914f9 -> 000000000000
0023120914f9 ARP address is yours
ARP packet: 0023120914f9 -> 000000000000
0023120914f9 ARP address is yours
ARP packet: 0023120914f9 -> 000000000000
0023120914f9 ARP address is yours
ARP packet: 0023120914f9 -> 000000000000
0023120914f9 ARP address is yours
ARP packet: 0015af772a39 -> 000000000000
0015af772a39 intruder!
ARP packet: 001c10f48be6 -> 000000000000
001c10f48be6 intruder!
ARP packet: 0023329dcdf5 -> 001c10f48be6
0023329dcdf5 ARP address is yours

Thursday, February 5, 2009

Lego Mindstorm NXT controlled via a perl bot ie LEGO::NXT

Ok so I have connected the NXT brick to my mac via bluetooth using these instructions:
http://juju.org/articles/2006/10/22/bluetooth-serial-port-to-nxt-in-osx
Yes Yes I know there for ruby...fuck it.
Ok so after that I have this script running on my computer in perl using lego::nxt and some other modules that you may or may not already have installed. Install all those modules. Now the next thing you need to do is change some of the variables, this bot connects to irc.malvager.com in room #malvager, with a name of nxtbot and a random number appended.


**I'll write a much more thorough and interesting post later about all of this but I am very busy tonight, and just wanted to get some content out.**


If you private message the bot his motor runs.

Here's the script:

use Sys::Hostname;
use Net::IRC;
use strict;
use warnings;
use LEGO::NXT;
use LEGO::NXT::Constants qw(:DEFAULT);
use LEGO::NXT::MacBlueComm;
#This is a wait, so that if the user isn't connected to a network
#it will wait 45 seconds giving them plenty of times to get connected
my $host = hostname();
my $capsule = int(rand(99));
my $hoster = 'nxtbot'.$capsule;
my $irc = new Net::IRC;
my $dev = new LEGO::NXT::MacBlueComm('/dev/tty.NXT-DevB-1');
my $bt = new LEGO::NXT( $dev );
my $speed = 100;
my $tachoticks = 1000;

my $conn = $irc->newconn(
Server => shift || 'irc.malvager.com',
Port => shift || '6667',
Nick => $hoster,
Ircname => 'I like to greet!',
Username => 'fucker'
);

# We're going to add this to the conn hash so we know what channel we
# want to operate in.
$conn->{channel} = shift || '#malvager';

sub on_connect {

# shift in our connection object that is passed automatically
my $conn = shift;

# when we connect, join our channel and greet it
$conn->join($conn->{channel});
$conn->privmsg($conn->{channel}, 'Hello everyone!');
$conn->{connected} = 1;

}

sub on_join {

# get our connection object and the event object, which is passed
# with this event automatically
my ($conn, $event) = @_;

# this is the nick that just joined
my $nick = $event->{nick};
# say hello to the nick in public
$conn->privmsg($conn->{channel}, "Fuck You, $nick!");
}

sub on_part {

# pretty much the same as above

my ($conn, $event) = @_;

my $nick = $event->{nick};
$conn->privmsg($conn->{channel}, "Such a dick, $nick!");

}

sub on_msg {
my ($conn, $event) = @_;
my $text = $event->{args}[0];
$bt->set_output_state( $NXT_NORET, $NXT_MOTOR_A, $speed, $NXT_MOTOR_ON|$NXT_REGULATED, $NXT_REGULATION_MODE_MOTOR_SPEED, 0, $NXT_MOTOR_RUN_STATE_RUNNING, $tachoticks );
}
sub on_public {
# on an event, we get connection object and event hash
# regex the text to see if it begins with clip

# $event->{to}[0] is the channel where this was said
}
$conn->add_handler('public', \&on_public);

$conn->add_handler('msg', \&on_msg);
# add event handlers for join and part events
$conn->add_handler('join', \&on_join);
$conn->add_handler('part', \&on_part);

# The end of MOTD (message of the day), numbered 376 signifies we've connect
$conn->add_handler('376', \&on_connect);

#ccgenerator
$irc->start();