2023 m. vasario 26 d., sekmadienis

How to read python documentation?

For example we will read documentation for tuple:

$ python3 -m pydoc tuple

2023 m. vasario 22 d., trečiadienis

Installing new python3.10 version to server

Installing new version ex: python3.10and running:


virtualenv --python=/usr/bin/python3.10 ven

will encounter 

he following packages were automatically installed and are no longer required:
  libdvdnav4 libdvdread7 libegl-mesa0 libegl1 libfwupdplugin1 libjansson4 libldb2 liblua5.2-0 libpython3.11-minimal libpython3.11-stdlib libsmbclient libtalloc2 libtevent0 libva-wayland2 libwbclient0 libxmlb1
  mpv python3-ldb python3-pyxattr python3-talloc python3.11-minimal rtmpdump samba-libs


What you need is this:


$ sudo apt-get install python3.10-distutils


Also pip will complain:

    from pip._vendor import html5lib, requests
ImportError: cannot import name 'html5lib' from 'pip._vendor' (/home/sup/scripts/Ton/lave_telegram_bot/venv/lib/python3.10/site-packages/pip/_vendor/__init__.py)

 

$ curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

 

Another pip error


      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]
 
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for crc16

Fix:

$ sudo apt install python3.10-dev


2023 m. vasario 15 d., trečiadienis

How to debug with chrome developer tools

 Great guide here

python structs and bytes

Comprehensive video about str and bytes

Script to get ICMP packet data:

https://gist.github.com/Paulius11/a49d9c8443d7477bb546f85c4a098d9f

Working with TCP/IP protocol stack:

 

Ethernet Frame Format 

 

eth_header=struct.unpack('!6s6sH', data)

 

 ICMP headers
https://th.bing.com/th/id/R.896fd1f80906bc6b76fb37ab508b1019?rik=%2bzHw3WcocYKhog&riu=http%3a%2f%2fwww.techbooksforfree.com%2fintro_to_data_com%2fstdimages%2fpage247.gif&ehk=IFqgBioiyL47m1UlVNpWIRL0c7nfPCFFBtS2%2bwrMdSU%3d&risl=&pid=ImgRaw&r=0
Internet Protocol Header

Internet Protocol header struct - !BBHHHBBH4s4s
   


# s    char[]    bytes

# H (unsigned short) Integer  = 2 (standard octets)

# B Integer  = 1 (standard octets)

eth_header=struct.unpack('!6s6sH', data)

icmp_type, code, checksum, packet_id, sequence = struct.unpack('!BBHHH', packet[20:28])

https://www.binarytides.com/python-packet-sniffer-code-linux/ -

https://www.bitforestinfo.com/blog/02/15/how-to-write-simple-packet-sniffer.html