I need to change the tcp/ip headers of packets caught with Net::PCAP. I know this is possible with Net::RawIP, but this doesn't work under windows?
Is there a module for this that works with windows? Is there at least to do this in windows with another programming language that I can call in perl, such as C?
To demonstrate what I want to do, here is the code using Net::RawIP, which does not work under windows because I can't install the module:
$n = Net::RawIP->new({
ip => {
saddr => 'my.target.lan',
daddr => 'my.target.lan',
},
tcp => {
source => 139,
dest => 139,
psh => 1,
syn => 1,
data => $your_data
},
});
$n->send();
Try pcap_sendpacket using this per module https://metacpan.org/pod/Net::Pcap
Related
I have a simple sending email perl code.
use strict;
use warnings;
use Time::Format;
use Email::MIME;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP;
my $message = Email::MIME->create(
header_str => [
From => 'me#provider.com',
To => 'me#provider.com',
Subject => 'test',
],
attributes => {
encoding => 'quoted-printable',
charset => 'ISO-8859-1',
},
body_str => 'stefy test',
);
my $transport = Email::Sender::Transport::SMTP->new({
host => 'my.server.smtp',
port => 25,
});
sendmail($message, { transport => $transport });
I can it run with success in one system but not another.
Windows 7 professional -> success
Window Server 2008 -> failure
this is the exception I get:
unable to establish SMTP connection to my.server.smtp port 25
Trace begun at D:\strawberryperl\perl\site\lib\Email\Sender\Transport\SMTP.pm line 193 Email::Sender::Transport::SMTP::_throw('Email::Sender::Transport::SMTP=HASH(0x38
0fef8)', 'unable to establish SMTP connection to my.server.smtp port 25') called at D:\strawberryperl\perl\site\lib\Email\Sender\Transport\SMTP.pm line 143
Any idea ?
thank you
update of the perl version fixed the problem.
This is perl 5, version 26, subversion 2 (v5.26.2) built for MSWin32-x64-multi-t
hread
I'm trying to send some data over TCP using Net::RawIP in Perl. Unfortunately i get the error
sendto() at /usr/lib/x86_64-linus-gnu/perl5/5.24/Net/RawIP.pm line 630
if the TCP data field is bigger than about 1470 characters:
my $n = Net::RawIP->new({
ip => {
saddr => '[src]',
daddr => '[dst]',
},
tcp => {
source => 7777,
dest => 7777,
data => "x" x 150
}
});
$n->send;
works, but
my $n = Net::RawIP->new({
ip => {
saddr => '[src]',
daddr => '[dst]',
},
tcp => {
source => 7777,
dest => 7777,
data => "x" x 1500 # size changed here
}
});
$n->send;
crashes. Any ideas why this happens?
You're building a packet that's too large, so sendto is returning error EMSGSIZE.
EMSGSIZE
The socket type requires that message be sent atomically, and the size of the message to be sent made this impossible.
It's no mystery it starts failing around 1500; that's the maximum an Ethernet frame can carry.
You need to use multiple packets or multiple packet fragments.
I am using SNMP package to create SNMPv3 session. But I am not sure how to pass transport information as UDP6 as I think default behavior is UDP. As far as I know that when use Net::SNMP to create session then we have "domain" parameter to classify between ipv4 and ipv6 address . But the same is not applicable to SNMP::Session. Can you please let me know how to pass transport information?
new SNMP::Session(DestHost => $self->{'ip'},
version => 3,
RemotePort => $self->{'port'},
SecEngineId => ‘0x8888233356',
SecName => $hashVal{'userName'},
AuthProto => $authProto,
AuthPass => $hashVal{'authPW'},
PrivProto => $privProto,
PrivPass => $hashVal{'privPW'},
SecLevel => $hashVal{‘secLevel’');
I have an dancer webapp that I'm trying to test, and I have a few issues related to paths. It appears that the appdir setting isn't being set correctly.
The top of my test code is:
use MyApp;
use Dancer::Test;
if I dump out the settings (using dd from Data::Dump) from:
my $settings = Dancer::Config::settings();
dd $settings;
I get:
{ appdir => "/Library/WebServer/Documents/myapp/lib",
apphandler => "Standalone",
auto_reload => 0,
charset => "",
confdir => "/Library/WebServer/Documents/myapp/lib",
content_type => "text/html",
daemon => 0,
engines => {},
envdir => "/Library/WebServer/Documents/myapp/lib/environments",
environment => "development",
handlers => {},
logger => "file",
plugins => {},
port => 3000,
public => "/Library/WebServer/Documents/myapp/lib/public",
server => "0.0.0.0",
server_tokens => 1,
startup_info => 1,
template => "simple",
traces => 0,
views => "/Library/WebServer/Documents/myapp/lib/views",
warnings => 0}
clearly it's not setting the appdir correctly. It doesn't appear that it matters how I call code (i.e. the working directory).
I've been calling it as perl -I lib -I ../lib t/001_base.t with the additional library calls as MyApp.pm needs modules in both lib and ../lib.
When I run the same code as a standalone webapp which is the following in bin/app.pl which has the code:
use Dancer;
use MyApp;
dance;
dumping the settings gives me the right appdir, which loads the configuration file and sets all of the other correctly.
In my test code, I thought that adding the lines:
Dancer::set appdir=>"/Library/WebServer/Documents/myapp"
Dancer::Config->load;
would do it. However that sets the appdir correctly, but doesn't change any other parameters. From the Dancer::Test code, there is an import command which appears to do what I want, but didn't help at all. Any other thoughts?
I run snmptrapd and can see incoming trap, when send trap via snmptrap
snmptrap -c public -v 2c localhost "" 1.3.3.3.3.3.3.3 1.2.2.2.2.2.2 s "Aliens here"
But I no have trap, when send via Perl script
use SNMP;
$sess = new SNMP::Session(DestHost => '127.0.0.1', RemotePort => "162" );
$sess->trap(enterprise=>'.1.3.6.1.4.1.2021', # or 'ucdavis' [default]
agent => '127.0.0.1', # or 'localhost',[dflt 1st intf on host]
generic => specific, # can be omitted if 'specific' supplied
specific => 5, # can be omitted if 'generic' supplied
uptime => 1234, # dflt to localhost uptime (0 on win32)
[[ifIndex, 1, 1],[sysLocation, 0, "here"]]);
What's wrong?
Your second version i.e. the perl one is not specifying community or version, unlike the first one. Try adding them
$sess = new SNMP::Session(DestHost => '127.0.0.1',
RemotePort => "162",
Community => "public,
Version => 2);
Also see http://www.remothelast.altervista.org/SNMP_Perl.html
and http://www.net-snmp.org/docs/perl-SNMP-README.html for SNMP::Session usage.