Warning: mkdir(): No space left on device in /var/www/tg-me/post.php on line 37

Warning: file_put_contents(aCache/aDaily/post/ManjusakaH/--): Failed to open stream: No such file or directory in /var/www/tg-me/post.php on line 50
Manjusaka 的碎碎念(以及摇曳露营 S4 制作确定!) | Telegram Webview: ManjusakaH/452 -
Telegram Group & Telegram Channel
Forwarded from Welcome to the Black Parade
开始吹 bpfsnoop (https://github.com/bpfsnoop/bpfsnoop),我至少会在三个场景使用它

1. disas kernel

之前我都是用 gdb -ex 'x/100i 0x'$(ksym skb_gso_validate_network_len) -ex q vmlinux /proc/kcore 这种蹩脚的方式去看汇编;若是 bpf prog 会用 bpftool p d 。但前者要手算 call 的目标函数,后者又长期有 bug (https://github.com/libbpf/bpftool/issues/109)。

但是以后我会用
bpfsnoop -d -k ip_rcv


bpfsnoop -d -p n:cil_to_overlay

来代替 gdb。输出非常好(图一),有颜色,有行号,有正确的 call 指令解析。

2. 用 --output-arg --filter-arg --filter-pkt 做 skb 观测

之前讨论过一个 nf postrouting 不会两次处理同一个 skb 的问题,本质是要观测 skb->_nfct 在生命期内的变化,用 bpfsnoop 可以一步到位:
bpfsnoop --filter-pkt 'icmp and dst host 10.244.2.2'  -t '*:(struct sk_buff *)skb' --output-pkt --output-arg 'skb->_nfct' 

虽然目前还不支持更复杂的操作,比如想观测 skb_sec_path(skb) 则需要写成 --output-arg 'skb->extensions->offset[1] << 3' 然而并不支持,但大部分简单的场景够用了。

3. 用 --output-lbr 观测 bpf prog

bpf prog 自身的观测性一直比较恶心,用 lbr 和 kprobe on bpf helpers 是目前为止我所知的唯二办法,而 bpfsnoop 是唯一实现了前者工程化的工具。(其实两者结合才是最吼的)

比如排查 https://github.com/cilium/cilium/issues/35023 的时候需要找到 bpf 运行的提前返回点,可以先无脑观测 bpf prog 退出时的 lbr
bpfsnoop -p i:7963 --output-lbr --filter-pkt 'dst host 1.1.1.1 and tcp[tcpflags]=tcp-syn' -m exit

然后再根据结果往上以 bpf helper 为节点回溯
bpfsnoop -k bpf_skb_event_output --output-lbr --filter-pkt 'dst host 1.1.1.1 and tcp[tcpflags]=tcp-syn' -m entry

最终定位代码执行流



tg-me.com/ManjusakaH/452
Create:
Last Update:

开始吹 bpfsnoop (https://github.com/bpfsnoop/bpfsnoop),我至少会在三个场景使用它

1. disas kernel

之前我都是用 gdb -ex 'x/100i 0x'$(ksym skb_gso_validate_network_len) -ex q vmlinux /proc/kcore 这种蹩脚的方式去看汇编;若是 bpf prog 会用 bpftool p d 。但前者要手算 call 的目标函数,后者又长期有 bug (https://github.com/libbpf/bpftool/issues/109)。

但是以后我会用

bpfsnoop -d -k ip_rcv


bpfsnoop -d -p n:cil_to_overlay

来代替 gdb。输出非常好(图一),有颜色,有行号,有正确的 call 指令解析。

2. 用 --output-arg --filter-arg --filter-pkt 做 skb 观测

之前讨论过一个 nf postrouting 不会两次处理同一个 skb 的问题,本质是要观测 skb->_nfct 在生命期内的变化,用 bpfsnoop 可以一步到位:
bpfsnoop --filter-pkt 'icmp and dst host 10.244.2.2'  -t '*:(struct sk_buff *)skb' --output-pkt --output-arg 'skb->_nfct' 

虽然目前还不支持更复杂的操作,比如想观测 skb_sec_path(skb) 则需要写成 --output-arg 'skb->extensions->offset[1] << 3' 然而并不支持,但大部分简单的场景够用了。

3. 用 --output-lbr 观测 bpf prog

bpf prog 自身的观测性一直比较恶心,用 lbr 和 kprobe on bpf helpers 是目前为止我所知的唯二办法,而 bpfsnoop 是唯一实现了前者工程化的工具。(其实两者结合才是最吼的)

比如排查 https://github.com/cilium/cilium/issues/35023 的时候需要找到 bpf 运行的提前返回点,可以先无脑观测 bpf prog 退出时的 lbr
bpfsnoop -p i:7963 --output-lbr --filter-pkt 'dst host 1.1.1.1 and tcp[tcpflags]=tcp-syn' -m exit

然后再根据结果往上以 bpf helper 为节点回溯
bpfsnoop -k bpf_skb_event_output --output-lbr --filter-pkt 'dst host 1.1.1.1 and tcp[tcpflags]=tcp-syn' -m entry

最终定位代码执行流

BY Manjusaka 的碎碎念(以及摇曳露营 S4 制作确定!)




Share with your friend now:
tg-me.com/ManjusakaH/452

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

Dump Scam in Leaked Telegram Chat

A leaked Telegram discussion by 50 so-called crypto influencers has exposed the extraordinary steps they take in order to profit on the back off unsuspecting defi investors. According to a leaked screenshot of the chat, an elaborate plan to defraud defi investors using the worthless “$Few” tokens had been hatched. $Few tokens would be airdropped to some of the influencers who in turn promoted these to unsuspecting followers on Twitter.

Telegram Be The Next Best SPAC

I have no inside knowledge of a potential stock listing of the popular anti-Whatsapp messaging app, Telegram. But I know this much, judging by most people I talk to, especially crypto investors, if Telegram ever went public, people would gobble it up. I know I would. I’m waiting for it. So is Sergei Sergienko, who claims he owns $800,000 of Telegram’s pre-initial coin offering (ICO) tokens. “If Telegram does a SPAC IPO, there would be demand for this issue. It would probably outstrip the interest we saw during the ICO. Why? Because as of right now Telegram looks like a liberal application that can accept anyone - right after WhatsApp and others have turn on the censorship,” he says.

telegram from it


Telegram Manjusaka 的碎碎念(以及摇曳露营 S4 制作确定!)
FROM USA