Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Help with Lorcon XS library

by Bpl (Scribe)
on Jul 20, 2020 at 15:33 UTC ( #11119545=perlquestion: print w/replies, xml ) Need Help??

Bpl has asked for the wisdom of the Perl Monks concerning the following question:

Hi perlmonkers! I spent the last 2 years studying computer security and related topics and since my first day of studies, I used perl as my first programming language and I (finally) would like to update an old library which can be great for penetration testing purposes: I am talking about the Net::Lorcon2 library, I started yesterday the rewriting and now, after 10-12 hours of developing, I encountered the first (persistent) problem: the XS code is extremely flawed, every time that I call the "lorcon_create" function (which accept 2 parameters, the interface and the driver) it says:  Net::Lorcon2::lorcon_create: driver is not a reference so, instead of calling:
use Net::Lorcon2 qw(:subs); my $driver = "iwlwifi"; my $if = "wlo1"; print Net::Lorcon2::lorcon_create($if, $driver);
I called
use Net::Lorcon2 qw(:subs); my $driver = "iwlwifi"; my $if = "wlo1"; print Net::Lorcon2::lorcon_create($if, \$driver);
obtaining only a Segmentation fault. I put the entirely library code here: https://easyupload.io/o120mv Hope in some helps! thanks. (p.s this is just a naif version of the library, I am using it only for the XS debug, do the normal "make" and "make install", do not try to use tests, they are still WIP :) )

Replies are listed 'Best First'.
Re: Help with Lorcon XS library
by davido (Cardinal) on Jul 20, 2020 at 18:19 UTC

    You probably should be working with that module's author or maintainer, and should submit a bug report via the issue tracker. See Net::Lorcon2. A proper bug report should include full steps to reproduce.


    Dave

      I am in contact with Patrice but he hasn't enough time. The problem stands probably in the XS code, if someone can try to install the module and execute  Net::Lorcon2::lorcon_create($if, $driver) could send the output? maybe my network card doesn't support Lorcon and crashes.

        "maybe my network card doesn't support Lorcon and crashes."

        You don't say which card. The Net::Lorcon2 documentarian leads to a dead repository for Lorcon2, where did you get it?

Re: Help with Lorcon XS library
by syphilis (Bishop) on Jul 21, 2020 at 01:02 UTC
    Hi,

    The SYNOPSIS section of the documentation (in Lorcon2.pm) indicates that you should be doing:
    my $driver = "iwlwifi"; my $if = "wlo1"; my $drv = lorcon_find_driver($driver); if (! $drv) { print STDERR "[-] Unable to find DRV for [$driver]\n"; exit 1; } my $lorcon = lorcon_create($if, $drv); if (! $lorcon) { print STDERR "[-] lorcon_create failed\n"; exit 1; }
    That is, you should be providing $drv (not $driver) as the second argument to lorcon_create().

    Cheers,
    Rob
      Hi! I know that, I toggled the  lorcon_fin_driver because every time causes an error crash, could you please test in your computer if it works? it would be extremely usefull for me. I am using a quite old computer and the wireless chip is quite flawed (thanks to me :) ) Regards Edoardo
        could you please test in your computer if it works?

        No, I'm not prepared to go to those lengths.
        But it if you're prepared to try things and give us useful feedback on what's happening then I (or someone else) might be ble to come up with some helpful diagnosis.

        For example, what output do you get if you run:
        use strict; use warnings; use Net::Lorcon2 qw(:subs); my $driver = "iwlwifi"; my $if = "wlo1"; my $drv = lorcon_find_driver($driver); if (! $drv) { print STDERR "[-] Unable to find DRV for [$driver]\n"; exit 1; } my $lorcon = lorcon_create($if, $drv); if (! $lorcon) { print STDERR "[-] lorcon_create failed\n"; exit 1; }
        If all goes well, it should produce no output.

        Update: Another one that might be helpful to run is the following (from the examples that ship with Net-Lorcon2-2.03 source):
        use strict; use warnings; use Net::Lorcon2 qw(:subs); my @cards = lorcon_list_drivers(); use Data::Dumper; print Dumper(\@cards);

        Cheers,
        Rob
Re: Help with Lorcon XS library
by syphilis (Bishop) on Jul 24, 2020 at 02:03 UTC
    Both Net::Lorcon2 and the lorcon library it relies on look very much like abandonware, but on Ubuntu-20.04 I've now built and installed the lorcon library from github and I've also built and installed the Net-Lorcon2-2.03 module from CPAN.

    The lorcon library issued a couple of compilation warnings, and neither make check nor make test don't run any tests.
    This does not inspire confidence.

    However, the Net-Lorcon2-2.03 module from CPAN built cleanly and passed tests, after I had installed a few netlink libraries using the package manager and re-built the lorcon library (which still issued compilation warnings).
    NOTE: In addition to the CPAN version of Net-Lorcon2-2.03, there's also a modified version by Bpl.
    But I'd like to deal with the CPAN version before I get to Bpl's.

    Here is the make test results for Net-Lorcon2-2.03 (from CPAN), perl-5.32.0:
    $ make test "/home/sisyphus/perl-5.32.0-d/bin/perl" -MExtUtils::Command::MM -e 'cp +_nonempty' -- Lorcon2.bs blib/arch/auto/Net/Lorcon2/Lorcon2.bs 644 PERL_DL_NONLAZY=1 "/home/sisyphus/perl-5.32.0-d/bin/perl" "-MExtUtils: +:Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; + test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/01-use.t ........... ok t/02-init.t .......... skipped: Set LORCON_IF and LORCON_INJ to a vali +d interface and injector name to run these tests t/03-device.t ........ skipped: Set LORCON_IF and LORCON_INJ to a vali +d interface and injector name to run these tests t/04-root.t .......... skipped: Set LORCON_IF and LORCON_INJ to a vali +d interface and injector name and run as root to run these tests t/05-pod-coverage.t .. ok t/06-test-pod.t ...... ok All tests successful. Files=6, Tests=3, 1 wallclock secs ( 0.05 usr 0.01 sys + 0.49 cusr + 0.03 csys = 0.58 CPU) Result: PASS
    Before I proceed further, I would like to run those skipped tests.
    How do I find valid interface and injector names that I can use ? (I have no idea what they are, and no idea if any exist on this system.)
    According to lorcon_list_drivers(), drivers named 'madwifing', 'tuntap' and 'mac80211' were found.

    Cheers,
    Rob
      Hi, Think that Lorcon2 can be considered a finished project, not a software with updates, one of the most interesting things that I've found is the possibility to sniff frames from multiple interfaces (already implemented but need testing). In general the Net::Lorcon2 can be an all-in-one perl module, with more features than Net::Pcap ( it uses it, in effect) and a better way of Net::Frame, it would be possible to built only with perl modules but the work would be bigger,maybe in future I'll do that :) Yes, my version is still unstable.. for now try the GomoR version. these interfaces are quite interesting, I'm start thinking that my computer doesn't support lorcon,you know, the tuntap device is an abstraction layer for sending and receiving packets directly from/to other application (they simulate an ethernet connection)
      a good module which offer the tuntap manipulation is Linux::TunTap
      The madwifing is my same driver, and it is considered the last way for sending packets (if the network card can't) while mac80211 is a wireless driver supported by Lorcon (and probably the suggested by the software), so in general it is possible to send infected packet with it. if you see the test you will understand a problem, this:
      if(!$ENV{LORCON_IF} || !$ENV{LORCON_INJ}) { plan skip_all => "Set LORCON_IF and LORCON_INJ to a valid interfac +e and injector name to run these tests # second test
      which means that it require 2 enviroment variables ( probably made by lorcon ), can you please try to inject some packet? if everything works, can you start using also my library? in maximun 1 day you will have the list of new function which I would like to test ( if you haven't enough time don't worry : ) Regards Edoardo small correction you want the drivers, not interface (which is like to wlan0, wlo1, lo ecc..) for find automatic interfaces, I suggest you the Net::Pcap::lookupdev() function from Net::Pcap,which permit you to find the best interface for sniffing.
      Hi again, finally I found a way for obtaining a "safe script", I added the function drv_madwifing_init from drv_madwfing.h
      use Net::Lorcon2 qw( :subs ); my $drv = Net::Lorcon2::lorcon_find_driver( "madwifing" ); my $Lorcon = Net::Lorcon2::lorcon_create("wlo1", $drv); print drv_madwifing_init($Lorcon); print Net::Lorcon2::lorcon_open_inject($Lorcon);
      It's seem that initializating the madwifing device there is no error ( intended as core dump), the output of the program is 1 and -1, this means that  drv_madwifing_init works, while lorcon_open_inject doesn't and it returns an error value ( still better than a core dump!) Regards Edoardo Mantovani.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11119545]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2021-10-23 03:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (86 votes). Check out past polls.

    Notices?