Kismet Wireless

Kismet Forums

 

Posted by:Elhanan
Subject:plugin to forward packets from kisemt to another process
Date:10:48:03 10/08/2017

hi..

is there a plugin that allows kismet to tunnel the messages it accepts outside? via sockets / http

i'm wondering if there's such a existing functionality even though
one of our colleagues already wrote such a thing, (here what it does basically, below), i just want to avoid maintaining it, because it's meant to run on a p.i, thus debugging and compiling will be a huge pain, it's sent to a java process which is also on the same p.i


void sendHttpMessage(const char *mac, const char* data, int signal)
{
CURL *curl;
CURLcode res;

/* In windows, this will init the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL);

/* get a curl handle */
curl = curl_easy_init();
if(curl) {
/* First set the URL that is about to receive our POST. This URL can
just as well be a https:// URL if that is what should receive the
data. */
curl_easy_setopt(curl, CURLOPT_URL, http_destnation_url);
/* Now specify the POST data */

char http_data[BUFFER_SIZE];
sprintf(http_data, "mac=%s&signal=%d&data=%s", mac, signal, data);

curl_easy_setopt(curl, CURLOPT_POSTFIELDS, http_data);

/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK){
char errorMsg[BUFFER_SIZE];
sprintf(errorMsg, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
_MSG(errorMsg, MSGFLAG_ERROR);
} else {
_MSG("Message sent successfully", MSGFLAG_INFO);
}

/* always cleanup */
curl_easy_cleanup(curl);
} else {
_MSG("Curl could not be initialized", MSGFLAG_ERROR);
}
}

bool startsWith(const char *pre, const char *str)
{
size_t lenpre = strlen(pre),
lenstr = strlen(str);
return lenstr < lenpre ? false : strncmp(pre, str, lenpre) == 0;
}

int httpfw_on_message(CHAINCALL_PARMS) {
kis_ieee80211_packinfo *packinfo =
(kis_ieee80211_packinfo *) in_pack->fetch(_PCM(PACK_COMP_80211));

// Grab the generic mangled frame
kis_datachunk *chunk =
(kis_datachunk *) in_pack->fetch(_PCM(PACK_COMP_MANGLEFRAME));

if (chunk == NULL) {
// Look for the 802.11 frame
if ((chunk =
(kis_datachunk *) in_pack->fetch(_PCM(PACK_COMP_80211FRAME))) == NULL) {

// Look for any link frame, we'll check the DLT soon
chunk =
(kis_datachunk *) in_pack->fetch(_PCM(PACK_COMP_LINKFRAME));
}
}


kis_layer1_packinfo *radioinfo =
(kis_layer1_packinfo *) in_pack->fetch(_PCM(PACK_COMP_RADIODATA));


/*
kis_gps_packinfo *gpsdata =
(kis_gps_packinfo *) in_pack->fetch(_PCM(PACK_COMP_GPS)); */

/*
kis_fcs_bytes *fcsdata =
(kis_fcs_bytes *) in_pack->fetch(_PCM(PACK_COMP_FCSBYTES));
*/


if (packinfo!=NULL){
mac_addr source = packinfo->source_mac;
string macstr = source.Mac2String();

if (startsWith(http_filter, macstr.c_str())){
if (chunk !=NULL){
char packet_data[BUFFER_SIZE];

unsigned int index;
for (index=0; index<chunk->length; index++) {
sprintf(packet_data+(index*2), "%02x", chunk->data[index]);
}
packet_data[index*2] = 0;

int signal = 0;

if (radioinfo!=NULL){
signal = radioinfo->signal_dbm;
} else {
_MSG("No radio information is present", MSGFLAG_ERROR);
}

char message[BUFFER_SIZE];
sprintf(message, "Message detected from tag: %s, signal:%d, data: %s", macstr.c_str(), signal, packet_data);
_MSG(message, MSGFLAG_INFO);

sendHttpMessage(macstr.c_str(), packet_data, signal);

} else {
char message[BUFFER_SIZE];
sprintf(message, "Message detected from tag %s - data: WARNING CHUNK IS NULL", macstr.c_str());
_MSG(message, MSGFLAG_INFO);
}
}
} else {
_MSG("NO PacketInfo detected", MSGFLAG_ERROR);
}

return 1;
}


Reply to this message