我正在尝试使用Pyshark读取.pcap文件中所有数据包的有效负载。我能够打开和读取文件,访问数据包及其其他信息,但无法找到用于访问数据包有效负载的正确属性/方法。有什么建议么 ?还有其他方法可以使用适用于Windows 10的python读取.pcap文件中的数据包有效载荷吗?
(我尝试使用Scapy代替Pyshark,但显然在Windows上运行Scapy存在一些问题,它在我的系统上也无法正常工作)
我在Internet和StackOverflow上的pyshark项目的不同代码段中找到了这些行。我尝试了它们,但是它们都不起作用:
import numpy as np
import matplotlib.pyplot as plt
Vs = np.array([0.5, 1, 1.5, 2])
Xs = np.array([[ 0.5, 0.2, 0.7],
[ 0.5, 0.3, 0.9],
[ 0.5, 0.5, 0.4],
[ 0.5, 0.7, 0.4],
[ 0.5, 0.9, 0.7],
[ 1, 0.15, 0.9],
[ 1, 0.35, 0.6],
[ 1, 0.45, 0.6],
[ 1, 0.67, 0.5],
[ 1, 0.85, 0.9],
[ 1.5, 0.1, 0.9],
[ 1.5, 0.3, 0.7],
[ 1.5, 0.76, 0.3],
[ 1.5, 0.98, 0.4],
[ 2, 0.21, 0.5],
[ 2, 0.46, 0.4],
[ 2, 0.66, 0.3],
[ 2, 0.76, 0.5],
[ 2, 0.88, 0.4],
[ 2, 0.99, 0.4]])
f, axs = plt.subplots(1, 1, figsize=(2.5,3))
#-------------------------------------
axs.set_xlim(0.38,1.0)
axs.set_ylim(0.0,4.0)
colors = plt.cm.gist_ncar(np.linspace(0,1,max(Vs)+3))
for idx,Val in enumerate(Vs):
axs.plot(Xs[Xs[:,0] == Val ,1], Xs[Xs[:,0] == Val ,2],'s',label=r"$Y={}$".format(Val), ms=3, color=colors[idx])
axs.plot(Xs[Xs[:,0] == Val ,1], Xs[Xs[:,0] == Val ,2]*Val/0.3,'-', label=r"$Y={}$".format(Val), ms=3, color=colors[idx])
axs.set_ylim(0.0,4.0)
axs.set_ylabel(r"$Y$ ", labelpad=2)
axs.set_xlabel(r"$X$ ", labelpad=2)
axs.set_yticks([0,0.5,1.0,1.5,2.0, 2.5, 3.0, 3.5, 4.0])
axs.set_xticks([0,0.5,1.0])
axs.legend(fontsize=6, loc=2, numpoints = 1, labelspacing=0.2,handletextpad=0.2, frameon=False)
f.savefig("tmp.pdf")
plt.show()
答案 0 :(得分:0)
此代码将打印与字段名称 tcp.payload 相关的值。
import React, { useState, useCallback } from "react";
// import "./App.css";
// let timeout; // this variable wasn't scoped inside the function?.
const EMPTY_STRING = "";
function App() {
const [name, setUserName] = useState("");
const [password, setUserPassword] = useState("");
const [showHackMessage, setShowHackMessage] = useState(false);
const [timer, setTimer] = useState(null);
const enterUserName = useCallback(
value => {
console.log(value);
setUserName(value);
},
[setUserName]
);
const enterUserPassword = useCallback(
value => {
setShowHackMessage(false);
setUserPassword(value);
console.log("password value", value);
if (timer) {
console.log("clear Timer=>", timer);
clearTimeout(timer);
}
if (value !== EMPTY_STRING) {
setTimer(setTimeout(() => setShowHackMessage(true), 5000));
console.log("set Timer=>", timer);
}
console.log("password", password);
},
[setUserPassword, setShowHackMessage, password, timer]
);
return (
<div className="App">
<p>Login-Hacker</p>
<input
name={"email"}
value={name}
onChange={e => enterUserName(e.target.value)}
/>
<br />
<br />
<input
name={"password"}
value={password}
onChange={e => enterUserPassword(e.target.value)}
/>
<p>Powered by Saurabh</p>
{name.length > 0 && <p>Your name is {name}</p>}
{password.length > 0 && <p>Your password is {password}</p>}
{showHackMessage && <p className="awesome">Now you are hacked!</p>}
</div>
);
}
export default App;
答案 1 :(得分:-1)
dir cap []。 这将为您提供与捕获相关的所有可访问属性。如果有有效负载选项,请查看那里。