Add classic dump function
This commit is contained in:
parent
b1ce5dea2e
commit
2b483965a8
19 changed files with 139 additions and 26 deletions
|
@ -28,10 +28,12 @@ find_package(Curses)
|
|||
|
||||
target_link_libraries(riddle ${Boost_LIBRARIES})
|
||||
target_link_libraries(riddle ${LIBPCAP})
|
||||
target_link_libraries(cigarette libDump)
|
||||
|
||||
target_link_libraries(cigarette ${Boost_LIBRARIES})
|
||||
target_link_libraries(cigarette ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries(cigarette libNetwork)
|
||||
target_link_libraries(cigarette libDump)
|
||||
|
||||
target_link_libraries(ranging ${Boost_LIBRARIES})
|
||||
target_link_libraries(ranging ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
@ -36,6 +36,7 @@
|
|||
#include "./libraries/libCigarette.h"
|
||||
#include "./commons/libAddress.h"
|
||||
#include "./commons/libPacket.h"
|
||||
#include "./commons/libDump.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
|
@ -160,8 +161,8 @@ int main(int argc, char **argv) {
|
|||
|
||||
if (vm.count("payload"))
|
||||
{
|
||||
//TODO - Visualizzare meglio il payload ?
|
||||
cout << " + Payload "<< pkg_tcpv4->getPayLoad() << endl;
|
||||
cout << " + Payload:" << endl;
|
||||
cout << libDump::classicDump(pkg_tcpv4->getPayLoad()) << endl;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/**
|
||||
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
|
||||
*
|
||||
*
|
||||
* Name : Project Riddle
|
||||
* Author : Andrea Bontempi
|
||||
* Version : 0.1 aplha
|
||||
* Description : Modular Network Sniffer
|
||||
*
|
||||
*
|
||||
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
|
||||
*
|
||||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
@ -22,6 +22,99 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this project. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
|
||||
*/
|
||||
*/
|
||||
|
||||
#define LINE 16
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <stdint.h>
|
||||
#include "libDump.h"
|
||||
|
||||
std::string libDump::classicDump(std::string input)
|
||||
{
|
||||
|
||||
std::stringstream out;
|
||||
int stringlen = input.length();
|
||||
int stringtodo = input.length();
|
||||
|
||||
for(uint16_t address = 0; address < stringlen; address += LINE*2)
|
||||
{
|
||||
out << "0x" << std::setfill('0') << std::setw(5) << std::hex << address/2 << " | ";
|
||||
|
||||
for(int i = 0; i < LINE*2; i+=2)
|
||||
{
|
||||
|
||||
if(i < stringtodo)
|
||||
{
|
||||
|
||||
out << std::hex << input[address + i];
|
||||
out << std::hex << input [address + i + 1] << " ";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
out << " ";
|
||||
|
||||
}
|
||||
|
||||
if(i == LINE-2)
|
||||
{
|
||||
out << " ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
out << "| ";
|
||||
|
||||
for(int i = 0; i < LINE*2; i+=2)
|
||||
{
|
||||
|
||||
if(i < stringtodo)
|
||||
{
|
||||
|
||||
std::string comp;
|
||||
comp += (char)input[address + i];
|
||||
comp += (char)input[address + i + 1];
|
||||
std::stringstream convert(comp);
|
||||
int temp;
|
||||
convert >> std::hex >> temp;
|
||||
if((temp>32)&&(temp<128))
|
||||
{
|
||||
out << (char)temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
out << ".";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
out << " ";
|
||||
|
||||
}
|
||||
|
||||
if(i == LINE-2)
|
||||
{
|
||||
out << " ";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
out << std::endl;
|
||||
|
||||
stringtodo = stringtodo - LINE*2;
|
||||
|
||||
}
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
@ -24,4 +24,19 @@
|
|||
* along with this project. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifndef LIHDUMP_H
|
||||
#define LIBDUMP_H
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace libDump {
|
||||
|
||||
std::string classicDump(std::string input);
|
||||
|
||||
}
|
||||
|
||||
#endif //LIBDUMP_H
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include "libRiddle.h"
|
||||
#include "../commons/libDump.h"
|
||||
|
||||
// Non mettere using namespace generali in header file.
|
||||
|
||||
|
@ -63,6 +64,7 @@ void hexDump(const unsigned char *start, struct pcap_pkthdr header)
|
|||
std::cout<<" uS: "<<header.ts.tv_usec;
|
||||
std::cout<<"] Received "<<header.len<<" byte:"<<std::endl;
|
||||
int index=0;
|
||||
// TODO
|
||||
while (header.len>16)
|
||||
{
|
||||
memPrint(start,16,index);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* This file is part of the project Riddle.
|
||||
*
|
||||
* Foobar is free software: you can redistribute it and/or modify
|
||||
* The project Riddle is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue