【问题标题】:How to get a human-readable date/time format from Beacon packets如何从 Beacon 数据包中获取人类可读的日期/时间格式
【发布时间】:2018-02-12 06:01:11
【问题描述】:

我想从 IEEE 802.11[a,b,g,n] 无线数据包中获取人类可读的日期/时间格式。

我们有一个名为 Aircrack-ng 的无线渗透测试开源项目。这个包有一个叫做 Airodump-ng 的工具。

我在 Airodump-ng 的源代码中找到了一个可以将此时间戳转换为可读格式的函数。

源代码:

https://github.com/aircrack-ng/aircrack-ng/blob/master/src/airodump-ng.c#L3039

https://github.com/aircrack-ng/aircrack-ng/blob/master/src/airodump-ng.c#L3044

#define TSTP_SEC 1000000ULL /* It's a 1 MHz clock, so a million ticks per second! */
#define TSTP_MIN (TSTP_SEC * 60ULL)
#define TSTP_HOUR (TSTP_MIN * 60ULL)
#define TSTP_DAY (TSTP_HOUR

static char *parse_timestamp(unsigned long long timestamp) {
        static char s[15];
        unsigned long long rem;
        unsigned int days, hours, mins, secs;

        days = timestamp / TSTP_DAY;
        rem = timestamp % TSTP_DAY;
        hours = rem / TSTP_HOUR;
        rem %= TSTP_HOUR;
        mins = rem / TSTP_MIN;
        rem %= TSTP_MIN;
        secs = rem / TSTP_SEC;

        snprintf(s, 14, "%3ud %02u:%02u:%02u", days, hours, mins, secs);

        return s; }

在 Airodump-ng 中,我看到了以下人类可读的接入点正常运行时间:

  • ADSL-ADSL: 0d 01:04:08
  • ViroooS:0d 18:13:10
  • Python2:0d 12:50:40
  • G4_3355: 0d 00:07:34
  • 苹果:4d 12:23:28
  • 玛雅:8 天 22:44:50

例如:G4_3355 作为接入点的正常运行时间约为 7 分钟。

为了测试,我有一个 PCAP 文件,你可以用 Wireshark 解析它。

PCAP文件下载链接:https://ufile.io/y0cca

Airodump-ng 工具的截图: https://ufile.io/qpv5t

How we can write above function (C codes) in Python !?

the <bsstimestamp>183258624319</bsstimestamp> as input. 

ts = 183258624319

result: a Date/Time  readable format.

note: the format of timestamps in wireshark is not like as above TS. https://www.epochconverter.com/

帮助我将此 PCAP 文件的时间戳转换为可读格式,如上述示例。

非常感谢。

【问题讨论】:

    标签: wireless beacon access-point human-readable


    【解决方案1】:

    简单示例:

    from scapy.all import *
    
    def print_timestamp(ts):
        TSTP_SEC =   1000000
        TSTP_MIN  = TSTP_SEC * 60
        TSTP_HOUR  = TSTP_MIN * 60
        TSTP_DAY  = TSTP_HOUR * 24
    
        days = ts / TSTP_DAY;
        rem = ts % TSTP_DAY;
        hours = rem / TSTP_HOUR;
        rem %= TSTP_HOUR;
        mins = rem / TSTP_MIN;
        rem %= TSTP_MIN;
        secs = rem / TSTP_SEC;
    
        print '%3ud %02u:%02u:%02u'% (days, hours, mins, secs)
    
    pkts = rdpcap('timestamp.cap')
    
    for pkt in pkts:
        if pkt.haslayer(Dot11Beacon) or pkt.haslayer(Dot11ProbeResp):
            print_timestamp(pkt.timestamp)
    

    【讨论】:

    • 亲爱的@Dmitry,非常感谢。 tnx tnx。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-02
    • 1970-01-01
    • 1970-01-01
    • 2015-05-26
    • 1970-01-01
    • 2017-09-04
    相关资源
    最近更新 更多