lastlog 0.2.3

Simple rust crate to read linux lastlog
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from struct import Struct
from typing import Any

def stringify(b: bytes) -> Any:
    if isinstance(b, bytes):
        return b.strip(b'\0').decode()
    return b

struct = Struct('hi32s4s32s256shhiii4i20s')
with open('/var/log/wtmp', 'rb') as f:
    offset  = 0
    content = f.read()
    while offset < len(content):
        record = list(map(stringify, struct.unpack_from(content, offset)))
        offset += struct.size
        print(record)