小编Sha*_*ark的帖子

通过特定接口的 ssh 客户端

如何强制客户端连接 ssh 通过特定接口进行通信?

我有一个带有 eth0 和 eth1 的服务器,我想强制所有 ssh 客户端通过 eth0。因此,当我的服务器上有很多 ssh 客户端时,我可以通过 eth1 更快地访问我的服务器。

编辑:服务器发起 ssh 客户端连接。

ssh networking

7
推荐指数
1
解决办法
3万
查看次数

如何设置发送数据包的TCP选项?

我是编程软件,可以将tcp数据包发送到主机.

我能够创建一个包含IP头,TCP标头和数据的数据包,但我无法管理如何添加MSS,NOP,STACK,窗口缩放或时间戳等TCP选项.

我的意思是我无法向TCP标头添加选项,计算正确的校验和以向主机发送一个好的TCP数据包.

我可以发送没有TCP选项的正确TCP数据包.

你觉得我在正确的补丁吗?有人可以帮帮我吗?

/* TCP Header structure */
struct tcphdr
{
    u_int16_t   th_sport;           /* source port */
    u_int16_t   th_dport;           /* destination port */
    u_int32_t   th_seq;             /* sequence number */
    u_int32_t   th_ack;             /* acknowledgement number */
#if __BYTE_ORDER == __LITTLE_ENDIAN
    u_int8_t    th_x2:4;            /* (unused) */
    u_int8_t    th_off:4;           /* data offset */
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
    u_int8_t    th_off:4;           /* data offset */
    u_int8_t    th_x2:4;            /* (unused) */
#endif
    u_int8_t    th_flags;
    # define    TH_FIN        0x01
    # define    TH_SYN        0x02
    # …
Run Code Online (Sandbox Code Playgroud)

c networking tcp

5
推荐指数
1
解决办法
2969
查看次数

如何从debian 64位上的tcphdr(sk_buff)结构访问数据/有效负载?

我正在使用一个小型防火墙,我必须从端口80(http)中的每个tcp数据包中检索数据以进行解析.这个代码适用于debian 32位虚拟机,我可以打印每个网页的标题,但是当我尝试加载我的内核模块并通过http端口传输一些数据时,它不打印任何数据.

当我编译时,它只在我的64位计算机上显示那些警告:

/home/dev3/C/FIREWALL/firewall.c: In function ‘hook_func’:
/home/dev3/C/FIREWALL/firewall.c:179: warning: cast from pointer to integer of different size
/home/dev3/C/FIREWALL/firewall.c:179: warning: cast to pointer from integer of different size
Run Code Online (Sandbox Code Playgroud)

有人有任何想法吗?

谢谢.

代码:

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter.h>

#undef __KERNEL__
#include <linux/netfilter_ipv4.h>
#define __KERNEL__

#include <linux/ip.h>
#include <linux/tcp.h>

static struct nf_hook_ops nfho;

unsigned int hook_func( unsigned int hooknum,
                    struct sk_buff * skb,
                    const struct net_device * in,
                    const struct net_device * out,
                    int (*okfn)(struct sk_buff *))
{
    struct iphdr    * iph;
    struct …
Run Code Online (Sandbox Code Playgroud)

c network-programming netfilter kernel-module

4
推荐指数
1
解决办法
1万
查看次数

如何在多个进程中同时生成随机数?

如何在C中生成随机数,以便在同一时间运行多个进程?

我想用srandrand,但我不知道如何(也许使用进程ID?).

c random

1
推荐指数
1
解决办法
2772
查看次数