rojansudev / libcrafter Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/libcrafter
Automatically exported from code.google.com/p/libcrafter
= Introduction = Libcrafter is a high level library for C++ designed to facilitate the creation and decoding of network packets. It is able to craft or decode packets of most common networks protocols, send them on the wire, capture them and match requests and replies. It enables the creation of networking tools in a few lines with a interface very similar to Scapy. A packet is described as layers that you stack one upon the other. Fields of each layer have useful default values that you can overload. The library is designed to be used in multithreaded programs where you can combine several tasks simultaneously. For example, you can easily design something that sniffs, mangles, and sends at the same time you are doing an ARP-Spoofing attack. It also contains a very naive implementation of the TCP/IP stack (fragmentation is no handled yet) at user level that enables working with TCP streams. This facilitates the creation of tools for data injection on arbitrary connections, IP spoofing and TCP/IP session hijacking. You can find information and news about the project at: http://code.google.com/p/libcrafter/ or you can follow the development of Libcrafter at: https://github.com/pellegre/libcrafter Libcrafter is also distributed in latest Backtrack releases. Examples are frequently updated on: https://github.com/pellegre/libcrafter-examples = Installation To compile libcrafter from the git repository you should have autoconf and libtool installed in your system : $ sudo apt-get install autoconf libtool Clone the repository and compile the library : $ git clone https://github.com/pellegre/libcrafter $ cd libcrafter/libcrafter $ ./autogen.sh $ make $ sudo make install $ sudo ldconfig = Information = Supported protocols are: Ethernet, SLL (Linux cooked-mode capture), ARP, DHCP, DHCP options, IP, IP options, IPv6, ICMP, ICMPv6, ICMP extensions, ICMPv6 extensions, TCP, TCP options, UDP and DNS IEEE802.11 coming soon! The primary developer of Libcrafter is Esteban Pellegrino. Contributions from libcrafter's users: * Bruno Nery : support ICMP extension (rfc4884) and MPLS extensions (rfc4950) for ICMPv6 and ICMPv4. * Joao Antunes : Several bug fixes * Lance Alt Performance enhancements for the GetPayload methods
The make fails on a recent Fedora:
<snip>
crafter/DNS.cpp:460:47: error: call of overloaded
‘SetContainerSection(std::vector<Crafter::DNS::DNSAnswer>&, __ns_sect,
ns_msg*)’ is ambiguous
crafter/DNS.cpp:460:47: note: candidates are:
crafter/DNS.cpp:338:13: note: void
SetContainerSection(std::vector<Crafter::DNS::DNSAnswer>&, ns_sect, ns_msg*)
crafter/DNS.h:252:15: note: void
Crafter::SetContainerSection(std::vector<Crafter::DNS::DNSAnswer>&, ns_sect,
ns_msg*)
crafter/DNS.cpp:461:48: error: call of overloaded
‘SetContainerSection(std::vector<Crafter::DNS::DNSAnswer>&, __ns_sect,
ns_msg*)’ is ambiguous
crafter/DNS.cpp:461:48: note: candidates are:
crafter/DNS.cpp:338:13: note: void
SetContainerSection(std::vector<Crafter::DNS::DNSAnswer>&, ns_sect, ns_msg*)
crafter/DNS.h:252:15: note: void
Crafter::SetContainerSection(std::vector<Crafter::DNS::DNSAnswer>&, ns_sect,
ns_msg*)
make[1]: *** [crafter/DNS.lo] Error 1
make[1]: Leaving directory
`/home/fab/Documents/repos/rpmbuild/SOURCES/crafter-0.1'
make: *** [all] Error 2
Original issue reported on code.google.com by [email protected]
on 14 Apr 2012 at 3:39
Hi,
In my last issue, I talked about bringing the code in Windows/MinGW. I think
many programmers need it. I've done some changes in the Libcrafter-0.2 to make
it usable for Windows/MinGW.
Do you agree to create a branch or something else of this project for Windows?
If yes, I can send you the code.
Original issue reported on code.google.com by [email protected]
on 30 May 2013 at 12:06
What steps will reproduce the problem?
RawLayer raw_header;
raw_header.SetPayload("SomePayload");
raw_header.RawString();
What is the expected output? What do you see instead?
The program should print the hex string of the raw header, instead a
segmentation fault happens.
Program received signal SIGSEGV, Segmentation fault.
0x001616a5 in Crafter::Layer::RawString (this=0xbffff5b4) at
crafter/Layer.cpp:109
109 std::cout << std::hex << (unsigned int)((byte *)raw_data)[i];
(gdb) where
#0 0x001616a5 in Crafter::Layer::RawString (this=0xbffff5b4) at
crafter/Layer.cpp:109
#1 0x08049bbf in main ()
(gdb) p i
$1 = 0
(gdb) list crafter/Layer.cpp:109
104 /* Print Payload */
105 void Crafter::Layer::RawString() const {
106 /* Print raw data in hexadecimal format */
107 for(size_t i = 0 ; i < bytes_size ; i++) {
108 std::cout << "\\x";
109 std::cout << std::hex << (unsigned int)((byte *)raw_data)[i];
110 }
111
112 LayerPayload.Print();
113
There is a bug on the RawString method of the Layer class.
Original issue reported on code.google.com by [email protected]
on 22 Apr 2012 at 10:57
What steps will reproduce the problem?
1.Set IP option, and generate 38 byte payload
unsigned char opt_arr[40];
ip_opt_h.SetOption(8);
ip_opt_h.SetPayload(opt_arr,38);
here is the IP header of the pkt with bad Checksum,
# 4f 00 02 fe 00 00 40 00 40 06 5c 20 be 6b d2 d3
# 41 94 2d 2c 88 28 d8 54 c4 05 b4 67 ea 22 b5 b3
# 2b ac 3e 11 5e 2a 6c 63 69 8e e2 c1 ac db b2 91
# 73 f3 38 aa 6b 10 fe 30 15 b3 97 ff
Original issue reported on code.google.com by [email protected]
on 6 Nov 2014 at 7:39
Currently, Ethernet is the only data link layer supported by libcrafter. A very
common data link layer (pseudo) protocol is SLL (Linux cooked-mode capture),
which is used, for example, when capturing from the "any" device using libpcap.
It also appears with other types of devices, such as PPP or virtual network
cards in virtual hosts.
Currently, it is possible to parse packets obtained from libpcap from this kind
of interface with the following code:
---- snip ----
#define SLL_HEADER_LEN 16
/* ... do something ... */
char* data;
int len;
/* ... obtain data ... */
Packet p;
p.PacketFromIP(data + SLL_HEADER_LEN, len - SLL_HEADER_LEN);
/* ... do something ... */
---- snip ----
It would be good to have a Packet::PacketFromSLL(...) or even a more generic
Packet::PacketFromDatalinkLayer (which would need to figure out what kind of
interface the packet came from).
Original issue reported on code.google.com by [email protected]
on 27 Apr 2012 at 4:49
What steps will reproduce the problem?
1. Prepare a Packet object;
2. Open a raw socket;
3. Call packet.RawSocketSend(socket, interface);
4. Call packet.RawSocketSend(socket, interface) again;
What is the expected output? What do you see instead?
Two packets are sent through the network is the expected output. Instead, only
one packet is seen.
What version of the product are you using? On what operating system?
HEAD of the repository, on Ubuntu Linux 11.10.
Please provide any additional information below.
The attached patch fixes the problem.
Original issue reported on code.google.com by [email protected]
on 25 Apr 2012 at 5:28
Attachments:
I followed the instructions given in the draft:
$ sudo apt-get install autoconf libtool
$ git clone https://github.com/pellegre/libcrafter
$ cd libcrafter/libcrafter
$ ./autogen.sh
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ make
$ sudo make install
$ sudo ldconfig
When run autogen.sh the next problem is appeared. How to solve it?
michael_k@tekoia-Vostro-3560 ~/CPP/libcrafter/libcrafter $ ./autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal ${ACLOCAL_FLAGS} --output=aclocal.m4t
sh: 1: aclocal: not found
autoreconf: aclocal failed with exit status: 127
michael_k@tekoia-Vostro-3560 ~/CPP/libcrafter/libcrafter $
Regards,
Michael Kanzieper
Original issue reported on code.google.com by [email protected]
on 18 May 2015 at 11:28
Hi,
I have tryed to compile on mac os x, but it not working; you can fix the code
for use it?
Thanks.
Original issue reported on code.google.com by antwal
on 16 Feb 2014 at 10:17
This is a great project in Linux. But why it's not portable to other operating
systems such as Windows/MinGW?
There is no technical problem to do it. I personally changed it by
- Removing DNS related files and RawSocket files
- Including some missed header files from Linux
- Adding some missed functions such as inet_pton
- Change some functions such as GetMyMac with portable codes
- Replacing SocketSend with pcap_sendpacket in Packet::SendRecv,...
It works fine and it's portable.
The most problem was raw-sockets (I think) but we can replace it with
pcap_sendpacket and achieve some good functionality in Windows.
I know my changes is ugly, but I believe we can port it and use the power of
Libcrafter in Windows too.
Original issue reported on code.google.com by [email protected]
on 8 Dec 2012 at 10:24
A common suggestion from several people is that the library should provide the
posibility to write packets using the functions `Print`, `HexDump`, etc. to
output files (using `ofstreams`).
Another common suggestion is that the library should be able to read and write
files in pcap format.
Taking note for next release...
Original issue reported on code.google.com by [email protected]
on 2 Apr 2012 at 9:33
What steps will reproduce the problem?
1. Run SimpleSniffer on eth0
2. ifconfig eth0 down
3. check top the load average will spike
What is the expected output? What do you see instead?
I would expect the the program to throw an error and and / or stop as it does
if you start the program and the port doesn't exist
terminate called after throwing an instance of 'std::runtime_error'
what(): Sniffer::Sniffer() : opening the sniffer: SIOCGIFHWADDR: No such device
What version of the product are you using? On what operating system?
Version 02 Backtrak5 r3
Original issue reported on code.google.com by [email protected]
on 24 Sep 2013 at 7:34
When Packet::RawSocketSend is called with a virtual network interface (such as
"venet0"), it fails on "setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, device,
iface.size())". Please note that in order to write to a raw socket it is not
necessary to bind to it.
Also, the error message reads "Setting IPPROTO_IP (IP_HDRINCL) option to raw
socket" (it should read "Setting SOL_SOCKET (SO_BINDTODEVICE) option to raw
socket").
Original issue reported on code.google.com by [email protected]
on 27 Apr 2012 at 4:55
What steps will reproduce the problem?
1.Run the Hello world program
2.
3.
What is the expected output? What do you see instead?
I get the following error-
BindLinkSocketToInterface() -> Getting Interface index: No such device
in my Fedora machine. I use crafter-0.2.
Please help
What version of the product are you using? On what operating system?
Crafter-0.2
Fedora OS
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 30 Sep 2014 at 12:59
What steps will reproduce the problem?
1. Download the attached code (trace_sniffer.cpp)
2. Compile it, run it as 'sudo ./trace_sniffer www.google.com 80'
What is the expected output? What do you see instead?
The expected output is:
----
Tracing www.google.com (74.125.224.49) at 80...
1 10.0.0.1 10.0.0.1 10.0.0.1
2 192.168.7.254 192.168.7.254 192.168.7.254
3 108.94.24.3 108.94.24.3 108.94.24.3
4 * * *
5 * * *
6 12.83.39.141 12.83.39.141 *
7 * * *
8 * * *
9 * * *
10 12.122.114.21 12.249.231.14 12.249.231.14
11 * * *
12 209.85.249.3 209.85.249.3 *
13 74.125.224.49 * *
----
Instead, I see:
----
Tracing www.google.com (74.125.224.148) at 80...
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Program received signal SIGABRT, Aborted.
----
What version of the product are you using? On what operating system?
Latest (HEAD), on Ubuntu 11.10.
Please provide any additional information below.
I also attached a packet capture from the program running. Also, running
'backtrace' on gdb gives me the following stack:
----
#0 0x00130416 in __kernel_vsyscall ()
#1 0x002d4c8f in raise () from /lib/i386-linux-gnu/libc.so.6
#2 0x002d82b5 in abort () from /lib/i386-linux-gnu/libc.so.6
#3 0x0024f4ed in __gnu_cxx::__verbose_terminate_handler() () from
/usr/lib/i386-linux-gnu/libstdc++.so.6
#4 0x0024d283 in ?? () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#5 0x0024d2bf in std::terminate() () from
/usr/lib/i386-linux-gnu/libstdc++.so.6
#6 0x0024d40e in __cxa_throw () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#7 0x0024da2f in operator new(unsigned int) () from
/usr/lib/i386-linux-gnu/libstdc++.so.6
#8 0x0024dafb in operator new[](unsigned int) () from
/usr/lib/i386-linux-gnu/libstdc++.so.6
#9 0x00180df0 in inflate (increase=-12, this=0xb7bf2140) at
crafter/Payload.cpp:37
#10 Crafter::Payload::inflate (this=0xb7bf2140, increase=-12) at
crafter/Payload.cpp:34
#11 0x00180e7e in Crafter::Payload::SetPayload (this=0xb7bf2140, data=0x805f314
"", ndata=4294967284) at crafter/Payload.cpp:76
#12 0x00175545 in Crafter::Layer::SetPayload (this=0xb7bf20f8, data=0x805f314
"", ndata=-12) at crafter/Layer.cpp:381
#13 0x0017842f in Crafter::Packet::PacketFromIP (this=0xb7bf21d0,
data=0x805f2e0 "E") at crafter/Packet.cpp:372
#14 0x001788a7 in Crafter::Packet::PacketFromIP (this=0xb7bf21d0, data=...) at
crafter/Packet.cpp:587
#15 0x08049deb in packetHandler (packet=0xb7bf2248, user=0x0) at
trace_sniffer.cpp:30
#16 0x00181e07 in process_packet (user=0x8057a30 "", header=0xb7bf22b4,
packet=0xb7c03046 "\b") at crafter/Sniffer.cpp:59
#17 0x00446d44 in ?? () from /usr/lib/i386-linux-gnu/libpcap.so.0.8
#18 0x00449651 in pcap_loop () from /usr/lib/i386-linux-gnu/libpcap.so.0.8
#19 0x00182432 in Crafter::Sniffer::Capture (this=0xbffff5ac, count=0,
user=0x6) at crafter/Sniffer.cpp:287
#20 0x0018254b in SpawnThread (thread_arg=0x8059318) at crafter/Sniffer.cpp:303
#21 0x0042bd31 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#22 0x0037a46e in clone () from /lib/i386-linux-gnu/libc.so.6
----
Original issue reported on code.google.com by [email protected]
on 25 Apr 2012 at 6:17
Attachments:
What steps will reproduce the problem?
1. TCP* tcp_layer = sniff_packet->GetLayer<TCP>();
cout << "Flags: " << tcp_layer->GetFlags() << endl;
2.
3.
What is the expected output? What do you see instead?
GetFlags() doesn't produce any output.
What version of the product are you using? On what operating system?
0.2
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 18 Jan 2015 at 11:15
Attachments:
What steps will reproduce the problem?
1. Clone source code
2. Compile it
3. Run 'git status'
What is the expected output? What do you see instead?
I expect:
---
# On branch master
nothing to commit (working directory clean)
---
I get:
---
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# libcrafter/.libs/
# libcrafter/Makefile
# libcrafter/config.h
# libcrafter/config.status
# libcrafter/crafter.pc
# libcrafter/crafter/.deps/
# libcrafter/crafter/.dirstamp
# libcrafter/crafterconfig.h
# libcrafter/libtool
# libcrafter/stamp-h1
# libcrafter/stamp-h2
nothing added to commit but untracked files present (use "git add" to track)
---
What version of the product are you using? On what operating system?
1753ce8af7da9e714c430f928c83fb9c764c25c9 (HEAD) on Ubuntu Linux 11.10.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 17 Apr 2012 at 11:06
What steps will reproduce the problem?
1. Clone the repository
2. Run ./configure && make
What is the expected output? What do you see instead?
Library compiles successfully would be expected. Instead, we see:
----
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash
/home/bruno/lcrafter/libcrafter/missing --run aclocal-1.11
cd . && /bin/bash /home/bruno/lcrafter/libcrafter/missing --run automake-1.11 --gnu
Makefile.am: required file `./COPYING' not found
Makefile.am: `automake --add-missing' can install `COPYING'
make: *** [Makefile.in] Error 1
----
What version of the product are you using? On what operating system?
Latest (1753ce8af7da9e714c430f928c83fb9c764c25c9). On Ubuntu 11.10.
Please provide any additional information below.
Running "./autogen.sh" before "./configure" solves the problem.
Original issue reported on code.google.com by [email protected]
on 19 Apr 2012 at 6:30
The following protocols must be implemented ASAP (listed in order of priority):
* DHCP
* IPv6
* IPSec
* BGP
* IGMP
Original issue reported on code.google.com by [email protected]
on 2 Apr 2012 at 10:36
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.