Skip to content

Instantly share code, notes, and snippets.

@mskf3000
Forked from s1037989/client-socat
Created October 7, 2023 07:59
Show Gist options
  • Save mskf3000/55d5d00f66abef6781955a5334f11063 to your computer and use it in GitHub Desktop.
Save mskf3000/55d5d00f66abef6781955a5334f11063 to your computer and use it in GitHub Desktop.
$ echo -n -e "\x3c\x97\x0e\x1d\x3f\x07\xf8\x32\xe4\xc0\x48\xab\x00\x02\x61\x62" | sudo socat -t 1 -lu -x -d -d -d -d - SOCKET-SENDTO:17:3:0:x0003x02000000x0000x00x06x3c970e1d3f070000
2020/06/22 04:34:56.306263 socat[762494] D getpid()
2020/06/22 04:34:56.306315 socat[762494] D getpid() -> 762494
2020/06/22 04:34:56.306322 socat[762494] D setenv("SOCAT_PID", "762494", 1)
2020/06/22 04:34:56.306329 socat[762494] D setenv() -> 0
2020/06/22 04:34:56.306332 socat[762494] D setenv("SOCAT_PPID", "762494", 1)
2020/06/22 04:34:56.306337 socat[762494] D setenv() -> 0
2020/06/22 04:34:56.306341 socat[762494] I socat by Gerhard Rieger and contributors - see www.dest-unreach.org
2020/06/22 04:34:56.306345 socat[762494] I This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)
2020/06/22 04:34:56.306349 socat[762494] I This product includes software written by Tim Hudson ([email protected])
2020/06/22 04:34:56.306353 socat[762494] D socat version 1.7.3.3 on Oct 26 2019 17:42:04
2020/06/22 04:34:56.306388 socat[762494] D setenv("SOCAT_VERSION", "1.7.3.3", 1)
2020/06/22 04:34:56.306393 socat[762494] D setenv() -> 0
2020/06/22 04:34:56.306398 socat[762494] D running on Linux version #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020, release 5.4.0-26-generic, machine x86_64
2020/06/22 04:34:56.306403 socat[762494] D argv[0]: "socat"
2020/06/22 04:34:56.306407 socat[762494] D argv[1]: "-t"
2020/06/22 04:34:56.306410 socat[762494] D argv[2]: "1"
2020/06/22 04:34:56.306414 socat[762494] D argv[3]: "-lu"
2020/06/22 04:34:56.306418 socat[762494] D argv[4]: "-x"
2020/06/22 04:34:56.306421 socat[762494] D argv[5]: "-d"
2020/06/22 04:34:56.306425 socat[762494] D argv[6]: "-d"
2020/06/22 04:34:56.306428 socat[762494] D argv[7]: "-d"
2020/06/22 04:34:56.306432 socat[762494] D argv[8]: "-d"
2020/06/22 04:34:56.306436 socat[762494] D argv[9]: "-"
2020/06/22 04:34:56.306439 socat[762494] D argv[10]: "SOCKET-SENDTO:17:3:0:x0003x02000000x0000x00x06x3c970e1d3f070000"
2020/06/22 04:34:56.306444 socat[762494] D sigaction(1, 0x7ffffe40c420, 0x0)
2020/06/22 04:34:56.306449 socat[762494] D sigaction() -> 0
2020/06/22 04:34:56.306452 socat[762494] D sigaction(2, 0x7ffffe40c420, 0x0)
2020/06/22 04:34:56.306457 socat[762494] D sigaction() -> 0
2020/06/22 04:34:56.306462 socat[762494] D sigaction(3, 0x7ffffe40c420, 0x0)
2020/06/22 04:34:56.306465 socat[762494] D sigaction() -> 0
2020/06/22 04:34:56.306468 socat[762494] D sigaction(4, 0x7ffffe40c420, 0x0)
2020/06/22 04:34:56.306472 socat[762494] D sigaction() -> 0
2020/06/22 04:34:56.306474 socat[762494] D sigaction(6, 0x7ffffe40c420, 0x0)
2020/06/22 04:34:56.306478 socat[762494] D sigaction() -> 0
2020/06/22 04:34:56.306480 socat[762494] D sigaction(7, 0x7ffffe40c420, 0x0)
2020/06/22 04:34:56.306484 socat[762494] D sigaction() -> 0
2020/06/22 04:34:56.306486 socat[762494] D sigaction(8, 0x7ffffe40c420, 0x0)
2020/06/22 04:34:56.306490 socat[762494] D sigaction() -> 0
2020/06/22 04:34:56.306492 socat[762494] D sigaction(11, 0x7ffffe40c420, 0x0)
2020/06/22 04:34:56.306496 socat[762494] D sigaction() -> 0
2020/06/22 04:34:56.306499 socat[762494] D sigaction(15, 0x7ffffe40c420, 0x0)
2020/06/22 04:34:56.306502 socat[762494] D sigaction() -> 0
2020/06/22 04:34:56.306505 socat[762494] D signal(13, 0x1)
2020/06/22 04:34:56.306509 socat[762494] D signal() -> 0x0
2020/06/22 04:34:56.306512 socat[762494] D atexit(0x5556ed2d1f90)
2020/06/22 04:34:56.306516 socat[762494] D atexit() -> 0
2020/06/22 04:34:56.306520 socat[762494] D calloc(1, 848)
2020/06/22 04:34:56.306524 socat[762494] D calloc() -> 0x5556eecde460
2020/06/22 04:34:56.306533 socat[762494] D malloc(1024)
2020/06/22 04:34:56.306539 socat[762494] D malloc() -> 0x5556eecdd4c0
2020/06/22 04:34:56.306543 socat[762494] D calloc(1, 848)
2020/06/22 04:34:56.306547 socat[762494] D calloc() -> 0x5556eecde7e0
2020/06/22 04:34:56.306551 socat[762494] D calloc(1, 848)
2020/06/22 04:34:56.306554 socat[762494] D calloc() -> 0x5556eecdeb40
2020/06/22 04:34:56.306558 socat[762494] D isatty(0)
2020/06/22 04:34:56.306563 socat[762494] D isatty() -> 0
2020/06/22 04:34:56.306568 socat[762494] D isatty(1)
2020/06/22 04:34:56.306574 socat[762494] D isatty() -> 1
2020/06/22 04:34:56.306578 socat[762494] D tcgetattr(1, 0x5556eecdec9c)
2020/06/22 04:34:56.306587 socat[762494] D tcgetattr(, {00004500,00000005,000000bf,00008a3b, 15,15, 03,1c,7f,15,04,00,01,00,11,13,1a,00,12,0f,17,16,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00}) -> 0
2020/06/22 04:34:56.306593 socat[762494] D malloc(128)
2020/06/22 04:34:56.306596 socat[762494] D malloc() -> 0x5556eecdeea0
2020/06/22 04:34:56.306601 socat[762494] D malloc(128)
2020/06/22 04:34:56.306604 socat[762494] D malloc() -> 0x5556eecdef30
2020/06/22 04:34:56.306608 socat[762494] N reading from and writing to stdio
2020/06/22 04:34:56.306611 socat[762494] D calloc(1, 848)
2020/06/22 04:34:56.306617 socat[762494] D calloc() -> 0x5556eecdefc0
2020/06/22 04:34:56.306625 socat[762494] D malloc(1024)
2020/06/22 04:34:56.306629 socat[762494] D malloc() -> 0x5556eecdf3e0
2020/06/22 04:34:56.306635 socat[762494] D socket(17, 3, 0)
2020/06/22 04:34:56.306647 socat[762494] I socket(17, 3, 0) -> 5
2020/06/22 04:34:56.306652 socat[762494] D fcntl(5, 2, 1)
2020/06/22 04:34:56.306657 socat[762494] D fcntl() -> 0
2020/06/22 04:34:56.306660 socat[762494] D getsockname(5, 0x7ffffe40c060, 0x7ffffe40c05c{112})
2020/06/22 04:34:56.306666 socat[762494] D getsockname(, {AF=17 AF=17 0x00000000000000000000ff7f0000}, {12}) -> 0
2020/06/22 04:34:56.306671 socat[762494] N successfully prepared local socket AF=17 AF=17 0x00000000000000000000ff7f0000
2020/06/22 04:34:56.306675 socat[762494] I resolved and opened all sock addresses
2020/06/22 04:34:56.306678 socat[762494] D malloc(16385)
2020/06/22 04:34:56.306682 socat[762494] D malloc() -> 0x5556eecdf7f0
2020/06/22 04:34:56.306685 socat[762494] N starting data transfer loop with FDs [0,1] and [5,5]
2020/06/22 04:34:56.306689 socat[762494] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:34:56.306693 socat[762494] D select(6, &0x21, &0x22, &0x0, NULL/0.000000)
2020/06/22 04:34:56.306701 socat[762494] D select -> (, 0x1, 0x22, 0x0, NULL/0.000000), 3
2020/06/22 04:34:56.306705 socat[762494] D read(0, 0x5556eecdf7f0, 8192)
2020/06/22 04:34:56.306712 socat[762494] D read -> 16
> 2020/06/22 04:34:56.306715 length=16 from=0 to=15
3c 97 0e 1d 3f 07 f8 32 e4 c0 48 ab 00 02 61 62
2020/06/22 04:34:56.306750 socat[762494] D sendto(5, 0x5556eecdf7f0[3c970e1d...], 16, 0, {AF=17 AF=17 0x000302000000000000063c970e1d}, 20)
2020/06/22 04:34:56.306771 socat[762494] D sendto() -> 16
2020/06/22 04:34:56.306774 socat[762494] D getsockname(5, 0x7ffffe40c110, 0x7ffffe40c10c{112})
2020/06/22 04:34:56.306780 socat[762494] D getsockname(, {AF=17 AF=17 0x00000000000000000000343a3334}, {12}) -> 0
2020/06/22 04:34:56.306784 socat[762494] N local address: AF=17 AF=17 0x00000000000000000000343a3334
2020/06/22 04:34:56.306787 socat[762494] I transferred 16 bytes from 0 to 5
2020/06/22 04:34:56.306790 socat[762494] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:34:56.306795 socat[762494] D select(6, &0x21, &0x20, &0x0, NULL/0.000000)
2020/06/22 04:34:56.306800 socat[762494] D select -> (, 0x1, 0x20, 0x0, NULL/0.000000), 2
2020/06/22 04:34:56.306804 socat[762494] D read(0, 0x5556eecdf7f0, 8192)
2020/06/22 04:34:56.306808 socat[762494] D read -> 0
2020/06/22 04:34:56.306811 socat[762494] N socket 1 (fd 0) is at EOF
2020/06/22 04:34:56.306814 socat[762494] I shutdown(5, 1)
2020/06/22 04:34:56.306818 socat[762494] D shutdown() -> -1
2020/06/22 04:34:56.306822 socat[762494] I shutdown(5, 1): Operation not supported
2020/06/22 04:34:56.306825 socat[762494] D data loop: sock1->eof=2, sock2->eof=0, closing=1, wasaction=1, total_to={0.000000}
2020/06/22 04:34:56.306829 socat[762494] D select(6, &0x20, &0x0, &0x0, &1.000000)
2020/06/22 04:34:57.307922 socat[762494] D select -> (, 0x0, 0x0, 0x0, &0.000000), 0
2020/06/22 04:34:57.307950 socat[762494] I poll timed out (no data within 1.000000 seconds)
2020/06/22 04:34:57.307964 socat[762494] D tcsetattr(1, 0, {00004500,00000005,000000bf,00008a3b, 15,15, 03,1c,7f,15,04,00,01,00,11,13,1a,00,12,0f,17,16,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00})
2020/06/22 04:34:57.307979 socat[762494] D tcsetattr() -> 0
2020/06/22 04:34:57.307988 socat[762494] I shutdown(5, 2)
2020/06/22 04:34:57.307995 socat[762494] D shutdown() -> -1
2020/06/22 04:34:57.308004 socat[762494] I shutdown(5, 2): Operation not supported
2020/06/22 04:34:57.308012 socat[762494] N exiting with status 0
2020/06/22 04:34:57.308020 socat[762494] D exit(0)
2020/06/22 04:34:57.308038 socat[762494] D starting xioexit()
2020/06/22 04:34:57.308044 socat[762494] D finished xioexit()
$ echo -n -e "\x3c\x97\x0e\x1d\x3f\x07\xf8\x32\xe4\xc0\x48\xab\x00\x02\x61\x62" | sudo socat -t 1 -lu -x -d -d -d -d - SOCKET-SENDTO:17:3:0:x0003x02000000x0000x00x06x3c970e1d3f070000
2020/06/22 04:35:07.649654 socat[762500] D getpid()
2020/06/22 04:35:07.649698 socat[762500] D getpid() -> 762500
2020/06/22 04:35:07.649703 socat[762500] D setenv("SOCAT_PID", "762500", 1)
2020/06/22 04:35:07.649707 socat[762500] D setenv() -> 0
2020/06/22 04:35:07.649710 socat[762500] D setenv("SOCAT_PPID", "762500", 1)
2020/06/22 04:35:07.649713 socat[762500] D setenv() -> 0
2020/06/22 04:35:07.649716 socat[762500] I socat by Gerhard Rieger and contributors - see www.dest-unreach.org
2020/06/22 04:35:07.649719 socat[762500] I This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)
2020/06/22 04:35:07.649722 socat[762500] I This product includes software written by Tim Hudson ([email protected])
2020/06/22 04:35:07.649724 socat[762500] D socat version 1.7.3.3 on Oct 26 2019 17:42:04
2020/06/22 04:35:07.649729 socat[762500] D setenv("SOCAT_VERSION", "1.7.3.3", 1)
2020/06/22 04:35:07.649732 socat[762500] D setenv() -> 0
2020/06/22 04:35:07.649737 socat[762500] D running on Linux version #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020, release 5.4.0-26-generic, machine x86_64
2020/06/22 04:35:07.649741 socat[762500] D argv[0]: "socat"
2020/06/22 04:35:07.649743 socat[762500] D argv[1]: "-t"
2020/06/22 04:35:07.649746 socat[762500] D argv[2]: "1"
2020/06/22 04:35:07.649749 socat[762500] D argv[3]: "-lu"
2020/06/22 04:35:07.649751 socat[762500] D argv[4]: "-x"
2020/06/22 04:35:07.649754 socat[762500] D argv[5]: "-d"
2020/06/22 04:35:07.649757 socat[762500] D argv[6]: "-d"
2020/06/22 04:35:07.649762 socat[762500] D argv[7]: "-d"
2020/06/22 04:35:07.649765 socat[762500] D argv[8]: "-d"
2020/06/22 04:35:07.649769 socat[762500] D argv[9]: "-"
2020/06/22 04:35:07.649772 socat[762500] D argv[10]: "SOCKET-SENDTO:17:3:0:x0003x02000000x0000x00x06x3c970e1d3f070000"
2020/06/22 04:35:07.649776 socat[762500] D sigaction(1, 0x7ffee38bb860, 0x0)
2020/06/22 04:35:07.649780 socat[762500] D sigaction() -> 0
2020/06/22 04:35:07.649784 socat[762500] D sigaction(2, 0x7ffee38bb860, 0x0)
2020/06/22 04:35:07.649788 socat[762500] D sigaction() -> 0
2020/06/22 04:35:07.649791 socat[762500] D sigaction(3, 0x7ffee38bb860, 0x0)
2020/06/22 04:35:07.649795 socat[762500] D sigaction() -> 0
2020/06/22 04:35:07.649798 socat[762500] D sigaction(4, 0x7ffee38bb860, 0x0)
2020/06/22 04:35:07.649802 socat[762500] D sigaction() -> 0
2020/06/22 04:35:07.649805 socat[762500] D sigaction(6, 0x7ffee38bb860, 0x0)
2020/06/22 04:35:07.649809 socat[762500] D sigaction() -> 0
2020/06/22 04:35:07.649812 socat[762500] D sigaction(7, 0x7ffee38bb860, 0x0)
2020/06/22 04:35:07.649815 socat[762500] D sigaction() -> 0
2020/06/22 04:35:07.649818 socat[762500] D sigaction(8, 0x7ffee38bb860, 0x0)
2020/06/22 04:35:07.649822 socat[762500] D sigaction() -> 0
2020/06/22 04:35:07.649825 socat[762500] D sigaction(11, 0x7ffee38bb860, 0x0)
2020/06/22 04:35:07.649829 socat[762500] D sigaction() -> 0
2020/06/22 04:35:07.649833 socat[762500] D sigaction(15, 0x7ffee38bb860, 0x0)
2020/06/22 04:35:07.649837 socat[762500] D sigaction() -> 0
2020/06/22 04:35:07.649840 socat[762500] D signal(13, 0x1)
2020/06/22 04:35:07.649844 socat[762500] D signal() -> 0x0
2020/06/22 04:35:07.649848 socat[762500] D atexit(0x55b6b0540f90)
2020/06/22 04:35:07.649850 socat[762500] D atexit() -> 0
2020/06/22 04:35:07.649853 socat[762500] D calloc(1, 848)
2020/06/22 04:35:07.649857 socat[762500] D calloc() -> 0x55b6b09d6460
2020/06/22 04:35:07.649862 socat[762500] D malloc(1024)
2020/06/22 04:35:07.649865 socat[762500] D malloc() -> 0x55b6b09d54c0
2020/06/22 04:35:07.649869 socat[762500] D calloc(1, 848)
2020/06/22 04:35:07.649872 socat[762500] D calloc() -> 0x55b6b09d67e0
2020/06/22 04:35:07.649875 socat[762500] D calloc(1, 848)
2020/06/22 04:35:07.649878 socat[762500] D calloc() -> 0x55b6b09d6b40
2020/06/22 04:35:07.649882 socat[762500] D isatty(0)
2020/06/22 04:35:07.649886 socat[762500] D isatty() -> 0
2020/06/22 04:35:07.649889 socat[762500] D isatty(1)
2020/06/22 04:35:07.649894 socat[762500] D isatty() -> 1
2020/06/22 04:35:07.649897 socat[762500] D tcgetattr(1, 0x55b6b09d6c9c)
2020/06/22 04:35:07.649905 socat[762500] D tcgetattr(, {00004500,00000005,000000bf,00008a3b, 15,15, 03,1c,7f,15,04,00,01,00,11,13,1a,00,12,0f,17,16,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00}) -> 0
2020/06/22 04:35:07.649910 socat[762500] D malloc(128)
2020/06/22 04:35:07.649913 socat[762500] D malloc() -> 0x55b6b09d6ea0
2020/06/22 04:35:07.649917 socat[762500] D malloc(128)
2020/06/22 04:35:07.649920 socat[762500] D malloc() -> 0x55b6b09d6f30
2020/06/22 04:35:07.649924 socat[762500] N reading from and writing to stdio
2020/06/22 04:35:07.649928 socat[762500] D calloc(1, 848)
2020/06/22 04:35:07.649933 socat[762500] D calloc() -> 0x55b6b09d6fc0
2020/06/22 04:35:07.649941 socat[762500] D malloc(1024)
2020/06/22 04:35:07.649944 socat[762500] D malloc() -> 0x55b6b09d73e0
2020/06/22 04:35:07.649949 socat[762500] D socket(17, 3, 0)
2020/06/22 04:35:07.649958 socat[762500] I socket(17, 3, 0) -> 5
2020/06/22 04:35:07.649963 socat[762500] D fcntl(5, 2, 1)
2020/06/22 04:35:07.649968 socat[762500] D fcntl() -> 0
2020/06/22 04:35:07.649972 socat[762500] D getsockname(5, 0x7ffee38bb4a0, 0x7ffee38bb49c{112})
2020/06/22 04:35:07.649978 socat[762500] D getsockname(, {AF=17 AF=17 0x00000000000000000000fe7f0000}, {12}) -> 0
2020/06/22 04:35:07.649983 socat[762500] N successfully prepared local socket AF=17 AF=17 0x00000000000000000000fe7f0000
2020/06/22 04:35:07.649987 socat[762500] I resolved and opened all sock addresses
2020/06/22 04:35:07.649990 socat[762500] D malloc(16385)
2020/06/22 04:35:07.649995 socat[762500] D malloc() -> 0x55b6b09d77f0
2020/06/22 04:35:07.649999 socat[762500] N starting data transfer loop with FDs [0,1] and [5,5]
2020/06/22 04:35:07.650003 socat[762500] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:35:07.650008 socat[762500] D select(6, &0x21, &0x22, &0x0, NULL/0.000000)
2020/06/22 04:35:07.650016 socat[762500] D select -> (, 0x1, 0x22, 0x0, NULL/0.000000), 3
2020/06/22 04:35:07.650021 socat[762500] D read(0, 0x55b6b09d77f0, 8192)
2020/06/22 04:35:07.650027 socat[762500] D read -> 16
> 2020/06/22 04:35:07.650032 length=16 from=0 to=15
3c 97 0e 1d 3f 07 f8 32 e4 c0 48 ab 00 02 61 62
2020/06/22 04:35:07.650075 socat[762500] D sendto(5, 0x55b6b09d77f0[3c970e1d...], 16, 0, {AF=17 AF=17 0x000302000000000000063c970e1d}, 20)
2020/06/22 04:35:07.650093 socat[762500] D sendto() -> 16
2020/06/22 04:35:07.650098 socat[762500] D getsockname(5, 0x7ffee38bb550, 0x7ffee38bb54c{112})
2020/06/22 04:35:07.650102 socat[762500] D getsockname(, {AF=17 AF=17 0x00000000000000000000343a3335}, {12}) -> 0
2020/06/22 04:35:07.650107 socat[762500] N local address: AF=17 AF=17 0x00000000000000000000343a3335
2020/06/22 04:35:07.650110 socat[762500] I transferred 16 bytes from 0 to 5
2020/06/22 04:35:07.650113 socat[762500] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:35:07.650118 socat[762500] D select(6, &0x21, &0x20, &0x0, NULL/0.000000)
2020/06/22 04:35:07.650124 socat[762500] D select -> (, 0x1, 0x20, 0x0, NULL/0.000000), 2
2020/06/22 04:35:07.650128 socat[762500] D read(0, 0x55b6b09d77f0, 8192)
2020/06/22 04:35:07.650133 socat[762500] D read -> 0
2020/06/22 04:35:07.650136 socat[762500] N socket 1 (fd 0) is at EOF
2020/06/22 04:35:07.650139 socat[762500] I shutdown(5, 1)
2020/06/22 04:35:07.650143 socat[762500] D shutdown() -> -1
2020/06/22 04:35:07.650150 socat[762500] I shutdown(5, 1): Operation not supported
2020/06/22 04:35:07.650153 socat[762500] D data loop: sock1->eof=2, sock2->eof=0, closing=1, wasaction=1, total_to={0.000000}
2020/06/22 04:35:07.650158 socat[762500] D select(6, &0x20, &0x0, &0x0, &1.000000)
2020/06/22 04:35:08.651251 socat[762500] D select -> (, 0x0, 0x0, 0x0, &0.000000), 0
2020/06/22 04:35:08.651301 socat[762500] I poll timed out (no data within 1.000000 seconds)
2020/06/22 04:35:08.651328 socat[762500] D tcsetattr(1, 0, {00004500,00000005,000000bf,00008a3b, 15,15, 03,1c,7f,15,04,00,01,00,11,13,1a,00,12,0f,17,16,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00})
2020/06/22 04:35:08.651360 socat[762500] D tcsetattr() -> 0
2020/06/22 04:35:08.651374 socat[762500] I shutdown(5, 2)
2020/06/22 04:35:08.651396 socat[762500] D shutdown() -> -1
2020/06/22 04:35:08.651412 socat[762500] I shutdown(5, 2): Operation not supported
2020/06/22 04:35:08.651427 socat[762500] N exiting with status 0
2020/06/22 04:35:08.651439 socat[762500] D exit(0)
2020/06/22 04:35:08.651477 socat[762500] D starting xioexit()
2020/06/22 04:35:08.651489 socat[762500] D finished xioexit()
$ sudo tcpdump -i enp0s31f6 -XX -n -e -# '(ether src 3c:97:0e:1d:3f:07 and ether dst f8:32:e4:c0:48:ab) or (ether src f8:32:e4:c0:48:ab and ether dst 3c:97:0e:1d:3f:07)'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp0s31f6, link-type EN10MB (Ethernet), capture size 262144 bytes
1 04:34:56.306762 f8:32:e4:c0:48:ab > 3c:97:0e:1d:3f:07, 802.3, length 2: [|llc]
0x0000: 6162 ab
0x0000: 3c97 0e1d 3f07 f832 e4c0 48ab 0002 6162 <...?..2..H...ab
2 04:34:56.323224 3c:97:0e:1d:3f:07 > f8:32:e4:c0:48:ab, 802.3, length 4: LLC, dsap Unknown (0x60) Group, ssap Unknown (0x62) Command, ctrl 0x6261: Supervisory, Receiver Ready, rcv seq 49, Flags [Command], length 46
0x0000: f832 e4c0 48ab 3c97 0e1d 3f07 0004 6162 .2..H.<...?...ab
0x0010: 6162 0000 0000 0000 0000 0000 0000 0000 ab..............
0x0020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0030: 0000 0000 0000 0000 0000 0000 ............
3 04:35:07.650086 f8:32:e4:c0:48:ab > 3c:97:0e:1d:3f:07, 802.3, length 2: [|llc]
0x0000: 6162 ab
0x0000: 3c97 0e1d 3f07 f832 e4c0 48ab 0002 6162 <...?..2..H...ab
4 04:35:07.651746 3c:97:0e:1d:3f:07 > f8:32:e4:c0:48:ab, 802.3, length 4: LLC, dsap Unknown (0x40) Group, ssap STP (0x42) Command, ctrl 0x4241: Supervisory, Receiver Ready, rcv seq 33, Flags [Command], length 46
0x0000: f832 e4c0 48ab 3c97 0e1d 3f07 0004 4142 .2..H.<...?...AB
0x0010: 4142 0000 0000 0000 0000 0000 0000 0000 AB..............
0x0020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0030: 0000 0000 0000 0000 0000 0000 ............
The server loop works great and the tcpdump shows in and out (2 packets, every time).
The only missing is a response that gets shown on the client. Honestly, doesn't matter, we just want to see the bytes, and tcpdump is fine for that.
$ socat -V
socat by Gerhard Rieger and contributors - see www.dest-unreach.org
socat version 1.7.3.3 on Oct 26 2019 17:42:04
running on Linux version #33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020, release 5.4.0-29-generic, machine x86_64
features:
#define WITH_STDIO 1
#define WITH_FDNUM 1
#define WITH_FILE 1
#define WITH_CREAT 1
#define WITH_GOPEN 1
#define WITH_TERMIOS 1
#define WITH_PIPE 1
#define WITH_UNIX 1
#define WITH_ABSTRACT_UNIXSOCKET 1
#define WITH_IP4 1
#define WITH_IP6 1
#define WITH_RAWIP 1
#define WITH_GENERICSOCKET 1
#define WITH_INTERFACE 1
#define WITH_TCP 1
#define WITH_UDP 1
#define WITH_SCTP 1
#define WITH_LISTEN 1
#define WITH_SOCKS4 1
#define WITH_SOCKS4A 1
#define WITH_PROXY 1
#define WITH_SYSTEM 1
#define WITH_EXEC 1
#undef WITH_READLINE
#define WITH_TUN 1
#define WITH_PTY 1
#define WITH_OPENSSL 1
#undef WITH_FIPS
#define WITH_LIBWRAP 1
#define WITH_SYCLS 1
#define WITH_FILAN 1
#define WITH_RETRY 1
#define WITH_MSGLEVEL 0 /*debug*/
$ sudo socat -b 2048 -lu -x -D -d -d -d -d SOCKET-RECVFROM:17:3:0:x0004x02000000x0000x00x00x0000000000000000 EXEC:/home/perly
$ cat perly
#!/usr/bin/perl
use IO::Select;
my $s = IO::Select->new;
$s->add(\*STDIN);
while ($s->can_read) {
my $buf;
sysread(STDIN, $buf, 1024) or next;
my $echo = substr($buf, 6, 6).substr($buf, 0, 6).substr($buf, 12, 2).uc(substr($buf, 14));
syswrite(STDOUT, $echo, length($echo));
}
$ sudo tcpdump -i enp0s25 -XX -# -n -e '(ether src f8:32:e4:c0:48:ab and ether dst 3c:97:0e:1d:3f:07) or (ether dst f8:32:e4:c0:48:ab and ether src 3c:97:0e:1d:3f:07)'
$ echo -n -e "\x3c\x97\x0e\x1d\x3f\x07\xf8\x32\xe4\xc0\x48\xab\x00\x02\x61\x62" | sudo socat -lu -x -d -d -d -d - SOCKET-SENDTO:17:3:0:x0003x02000000x0000x00x06xc970e1d3f070000
$ sudo tcpdump -i enp0s25 -XX -# -n -e '(ether src f8:32:e4:c0:48:ab and ether dst 3c:97:0e:1d:3f:07) or (ether dst f8:32:e4:c0:48:ab and ether src 3c:97:0e:1d:3f:07)'
ubuntu@ubuntu:~/Downloads$ libreoffice --headless --convert-to csv:"Text - txt - csv (StarCalc)":"9,,,," ~/Downloads/file_example_ODS_10.ods --outdir /tmp
javaldx: Could not find a Java Runtime Environment!
Please ensure that a JVM and the package libreoffice-java-common
is installed.
If it is already installed then try removing ~/.config/libreoffice/4/user/config/javasettings_Linux_*.xml
Warning: failed to read path from javaldx
convert /home/ubuntu/Downloads/file_example_ODS_10.ods -> /tmp/file_example_ODS_10.csv using filter : Text - txt - csv (StarCalc):9,,,,
Overwriting: /tmp/file_example_ODS_10.csv
ubuntu@ubuntu:~/Downloads$ cat /tmp/file_example_ODS_10.csv
0 First Name Last Name Gender Country Age Date Id
1 Dulce Abril Female United States 32 15/10/2017 1562
2 Mara Hashimoto Female Great Britain 25 16/08/2016 1582
3 Philip Gent Male France 36 21/05/2015 2587
4 Kathleen Hanner Female United States 25 15/10/2017 3549
5 Nereida Magwood Female United States 58 16/08/2016 2468
6 Gaston Brumm Male United States 24 21/05/2015 2554
7 Etta Hurn Female Great Britain 56 15/10/2017 3598
8 Earlean Melgar Female United States 27 16/08/2016 2456
9 Vincenza Weiland Female United States 40 21/05/2015 6548
$ cat perly
#!/usr/bin/perl
use strict;
use warnings;
use IO::Select;
my $s = IO::Select->new;
$s->add(\*STDIN);
my $loop = 0;
while ($s->can_read) {
my $frame;
sysread(STDIN, $frame, 1514) or next;
my %frame = detherize($frame);
my $echo = etherize(
dst => $frame{src},
src => $frame{dst},
len => "\x00\x04",
pay => toggle_case(++$loop => ($frame{pay} x 2)),
);
warn unpack('H*', $echo);
syswrite(STDOUT, $echo, length($echo));
}
sub toggle_case { shift() % 2 == 0 ? uc(shift) : lc(shift) }
sub etherize {
my %frame = @_;
my $frame = join '', map { $frame{$_} } qw(dst src len pay);
return $frame;
}
sub detherize {
my $frame = shift;
my $len = substr($frame, 12, 2);
my %frame = (
dst => substr($frame, 0, 6),
src => substr($frame, 6, 6),
len => $len,
pay => substr($frame, 14, 2),
);
return %frame;
}
$ sudo socat -b 2048 -x -D -d -d -d -d SOCKET-RECVFROM:17:3:0:x0004x02000000x0000x00x00x0000000000000000 EXEC:/home/stefan/perly
2020/06/22 04:34:44 socat[4087427] D getpid()
2020/06/22 04:34:44 socat[4087427] D getpid() -> 4087427
2020/06/22 04:34:44 socat[4087427] D setenv("SOCAT_PID", "4087427", 1)
2020/06/22 04:34:44 socat[4087427] D setenv() -> 0
2020/06/22 04:34:44 socat[4087427] D setenv("SOCAT_PPID", "4087427", 1)
2020/06/22 04:34:44 socat[4087427] D setenv() -> 0
2020/06/22 04:34:44 socat[4087427] I socat by Gerhard Rieger and contributors - see www.dest-unreach.org
2020/06/22 04:34:44 socat[4087427] I This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)
2020/06/22 04:34:44 socat[4087427] I This product includes software written by Tim Hudson ([email protected])
2020/06/22 04:34:44 socat[4087427] D socat version 1.7.3.3 on Oct 26 2019 17:42:04
2020/06/22 04:34:44 socat[4087427] D setenv("SOCAT_VERSION", "1.7.3.3", 1)
2020/06/22 04:34:44 socat[4087427] D setenv() -> 0
2020/06/22 04:34:44 socat[4087427] D running on Linux version #33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020, release 5.4.0-29-generic, machine x86_64
2020/06/22 04:34:44 socat[4087427] D argv[0]: "socat"
2020/06/22 04:34:44 socat[4087427] D argv[1]: "-b"
2020/06/22 04:34:44 socat[4087427] D argv[2]: "2048"
2020/06/22 04:34:44 socat[4087427] D argv[3]: "-x"
2020/06/22 04:34:44 socat[4087427] D argv[4]: "-D"
2020/06/22 04:34:44 socat[4087427] D argv[5]: "-d"
2020/06/22 04:34:44 socat[4087427] D argv[6]: "-d"
2020/06/22 04:34:44 socat[4087427] D argv[7]: "-d"
2020/06/22 04:34:44 socat[4087427] D argv[8]: "-d"
2020/06/22 04:34:44 socat[4087427] D argv[9]: "SOCKET-RECVFROM:17:3:0:x0004x02000000x0000x00x00x0000000000000000"
2020/06/22 04:34:44 socat[4087427] D argv[10]: "EXEC:/home/stefan/perly"
2020/06/22 04:34:44 socat[4087427] D sigaction(1, 0x7ffc1b806740, 0x0)
2020/06/22 04:34:44 socat[4087427] D sigaction() -> 0
2020/06/22 04:34:44 socat[4087427] D sigaction(2, 0x7ffc1b806740, 0x0)
2020/06/22 04:34:44 socat[4087427] D sigaction() -> 0
2020/06/22 04:34:44 socat[4087427] D sigaction(3, 0x7ffc1b806740, 0x0)
2020/06/22 04:34:44 socat[4087427] D sigaction() -> 0
2020/06/22 04:34:44 socat[4087427] D sigaction(4, 0x7ffc1b806740, 0x0)
2020/06/22 04:34:44 socat[4087427] D sigaction() -> 0
2020/06/22 04:34:44 socat[4087427] D sigaction(6, 0x7ffc1b806740, 0x0)
2020/06/22 04:34:44 socat[4087427] D sigaction() -> 0
2020/06/22 04:34:44 socat[4087427] D sigaction(7, 0x7ffc1b806740, 0x0)
2020/06/22 04:34:44 socat[4087427] D sigaction() -> 0
2020/06/22 04:34:44 socat[4087427] D sigaction(8, 0x7ffc1b806740, 0x0)
2020/06/22 04:34:44 socat[4087427] D sigaction() -> 0
2020/06/22 04:34:44 socat[4087427] D sigaction(11, 0x7ffc1b806740, 0x0)
2020/06/22 04:34:44 socat[4087427] D sigaction() -> 0
2020/06/22 04:34:44 socat[4087427] D sigaction(15, 0x7ffc1b806740, 0x0)
2020/06/22 04:34:44 socat[4087427] D sigaction() -> 0
2020/06/22 04:34:44 socat[4087427] D signal(13, 0x1)
2020/06/22 04:34:44 socat[4087427] D signal() -> 0x0
2020/06/22 04:34:44 socat[4087427] D atexit(0x5649e4841f90)
2020/06/22 04:34:44 socat[4087427] D atexit() -> 0
2020/06/22 04:34:44 socat[4087427] D calloc(1, 848)
2020/06/22 04:34:44 socat[4087427] D calloc() -> 0x5649e4b10790
2020/06/22 04:34:44 socat[4087427] D malloc(1024)
2020/06/22 04:34:44 socat[4087427] D malloc() -> 0x5649e4b10bb0
2020/06/22 04:34:44 socat[4087427] D socket(17, 3, 0)
2020/06/22 04:34:44 socat[4087427] I socket(17, 3, 0) -> 5
2020/06/22 04:34:44 socat[4087427] D fcntl(5, 2, 1)
2020/06/22 04:34:44 socat[4087427] D fcntl() -> 0
2020/06/22 04:34:44 socat[4087427] D bind(5, AF=17 AF=17 0x0004020000000000000000000000, 20)
2020/06/22 04:34:44 socat[4087427] D bind() -> 0
2020/06/22 04:34:44 socat[4087427] I starting recvfrom loop
2020/06/22 04:34:44 socat[4087427] I socket_init(): unknown address family 17
2020/06/22 04:34:44 socat[4087427] N receiving on AF=17 AF=17 0x0004020000000000000000000000
2020/06/22 04:34:44 socat[4087427] D select(6, &0x20, &0x0, &0x0, NULL/0.000000)
2020/06/22 04:34:56 socat[4087427] D select -> (, 0x20, 0x0, 0x0, NULL/0.000000), 1
2020/06/22 04:34:56 socat[4087427] D recvmsg(5, 0x7ffc1b805ad0{0x7ffc1b805b10,112,0x7ffc1b805a60,1,0x7ffc1b806190,1024,0}, 34)
2020/06/22 04:34:56 socat[4087427] D recvmsg(, {AF=17 AF=17 0x00040200000001000006f832e4c0,20,,1,,0,}, ) -> 60
2020/06/22 04:34:56 socat[4087427] N receiving packet from AF=17 AF=17 0x00040200000001000006f832e4c0
2020/06/22 04:34:56 socat[4087427] I permitting packet from AF=17 AF=17 0x00040200000001000006f832e4c0
2020/06/22 04:34:56 socat[4087427] D calloc(1, 848)
2020/06/22 04:34:56 socat[4087427] D calloc() -> 0x5649e4b10fc0
2020/06/22 04:34:56 socat[4087427] D malloc(1024)
2020/06/22 04:34:56 socat[4087427] D malloc() -> 0x5649e4b11d90
2020/06/22 04:34:56 socat[4087427] D malloc(128)
2020/06/22 04:34:56 socat[4087427] D malloc() -> 0x5649e4b11360
2020/06/22 04:34:56 socat[4087427] N forking off child, using socket for reading and writing
2020/06/22 04:34:56 socat[4087427] D socketpair(1, 1, 0, 0x7ffc1b8064a8)
2020/06/22 04:34:56 socat[4087427] I socketpair(1, 1, 0, {6,7}) -> 0
2020/06/22 04:34:56 socat[4087427] D malloc(128)
2020/06/22 04:34:56 socat[4087427] D malloc() -> 0x5649e4b113f0
2020/06/22 04:34:56 socat[4087427] D fcntl(6, 2, 1)
2020/06/22 04:34:56 socat[4087427] D fcntl() -> 0
2020/06/22 04:34:56 socat[4087427] D sigaction(17, 0x7ffc1b8063a0, 0x0)
2020/06/22 04:34:56 socat[4087427] D sigaction() -> 0
2020/06/22 04:34:56 socat[4087427] D fork()
2020/06/22 04:34:56 socat[4087427] D fork() -> 4087792
2020/06/22 04:34:56 socat[4087427] N forked off child process 4087792
2020/06/22 04:34:56 socat[4087427] N forked off child process 4087792
2020/06/22 04:34:56 socat[4087427] I close(7)
2020/06/22 04:34:56 socat[4087427] D close() -> 0
2020/06/22 04:34:56 socat[4087427] I resolved and opened all sock addresses
FD type device inode mode links uid gid rdev size blksize blocks atime mtime ctime cloexec flags sigown sigio
5: socket 0,9 23952365 0140777 1 0 0 0,0 0 4096 02020/06/22 04:34:56 socat[4087792] D fork() -> 0
2020/06/22 04:34:56 socat[4087792] D getpid()
2020/06/22 04:34:56 socat[4087792] D getpid() -> 4087792
Wed Dec 31 18:00:00 19692020/06/22 04:34:56 socat[4087792] I just born: child process 4087792
Wed Dec 31 18:00:00 1969 Wed Dec 31 18:00:00 19692020/06/22 04:34:56 socat[4087792] I close(4)
2020/06/22 04:34:56 socat[4087792] D close() -> 0
1 x0000022020/06/22 04:34:56 socat[4087792] I close(3)
0 02020/06/22 04:34:56 socat[4087792] D close() -> 0
DEBUG=0 REUSEADDR=0 TYPE=3 ERROR=0 DONTROUTE=0 BROADCAST=0 SNDBUF=212992 2020/06/22 04:34:56 socat[4087792] D signal(17, 0x0)
RCVBUF=212992 KEEPALIVE=0 OOBINLINE=0 2020/06/22 04:34:56 socat[4087792] D signal() -> 0x5649e484a4a0
NO_CHECK=0 PRIORITY=0 2020/06/22 04:34:56 socat[4087792] I close(6)
LINGER={0,0} BSDCOMPAT=0 2020/06/22 04:34:56 socat[4087792] D close() -> 0
REUSEPORT=0 2020/06/22 04:34:56 socat[4087792] D dup2(7, 0)
PASSCRED=0 PEERCRED={0,-1} 2020/06/22 04:34:56 socat[4087792] I dup2(7, 0) -> 0
RCVLOWAT=1 SNDLOWAT=1 2020/06/22 04:34:56 socat[4087792] D dup2(7, 1)
RCVTIMEO={0,0} SNDTIMEO={0,0} 2020/06/22 04:34:56 socat[4087792] I dup2(7, 1) -> 1
2020/06/22 04:34:56 socat[4087792] D fcntl(7, 2, 1)
BINDTODEVICE={0,0} 2020/06/22 04:34:56 socat[4087792] D fcntl() -> 0
ATTACH_FILTER={0,0} 2020/06/22 04:34:56 socat[4087792] I close(7)
AF=17 AF=17 0x000402000000010000063c970e1d2020/06/22 04:34:56 socat[4087792] D close() -> 0
**** NO FURTHER ANALYSIS FOR THIS SOCKET TYPE IMPLEMENTED2020/06/22 04:34:56 socat[4087792] D child: args = "/home/stefan/perly"
poll: IN,2020/06/22 04:34:56 socat[4087792] D malloc(64)
OUT,; FIONREAD=140720308486204; 2020/06/22 04:34:56 socat[4087792] D malloc() -> 0x5649e4b11480
recvmsg=1,
2020/06/22 04:34:56 socat[4087792] D malloc(19)
6: socket 0,9 23952382 0140777 1 0 0 0,0 0 4096 0 2020/06/22 04:34:56 socat[4087792] D malloc() -> 0x5649e4b121a0
Wed Dec 31 18:00:00 1969 2020/06/22 04:34:56 socat[4087792] D malloc(20)
2020/06/22 04:34:56 socat[4087792] D malloc() -> 0x5649e4b121c0
Wed Dec 31 18:00:00 1969 2020/06/22 04:34:56 socat[4087792] N execvp'ing "/home/stefan/perly"
Wed Dec 31 18:00:00 19692020/06/22 04:34:56 socat[4087792] D execvp("/home/stefan/perly", "/home/stefan/perly")
1 x000002 0 0DEBUG=0 REUSEADDR=0 TYPE=1 ERROR=0 DONTROUTE=0 BROADCAST=0 SNDBUF=212992 RCVBUF=212992 KEEPALIVE=0 OOBINLINE=0 NO_CHECK=0 PRIORITY=0 LINGER={0,0} BSDCOMPAT=0 REUSEPORT=0 PASSCRED=0 PEERCRED={4087427,0} RCVLOWAT=1 SNDLOWAT=1 RCVTIMEO={0,0} SNDTIMEO={0,0}BINDTODEVICE={0,0} ATTACH_FILTER={0,0} AF=1 "<anon>" <-> AF=1 "<anon>" poll: OUT,
2020/06/22 04:34:56 socat[4087427] D malloc(4097)
2020/06/22 04:34:56 socat[4087427] D malloc() -> 0x5649e4b121a0
2020/06/22 04:34:56 socat[4087427] N starting data transfer loop with FDs [5,5] and [6,6]
2020/06/22 04:34:56 socat[4087427] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:34:56 socat[4087427] D select(7, &0x60, &0x60, &0x0, NULL/0.000000)
2020/06/22 04:34:56 socat[4087427] D select -> (, 0x20, 0x60, 0x0, NULL/0.000000), 3
2020/06/22 04:34:56 socat[4087427] I socket_init(): unknown address family 17
2020/06/22 04:34:56 socat[4087427] D recvmsg(5, 0x7ffc1b805ef0{0x7ffc1b805f30,112,0x7ffc1b805ea0,1,0x7ffc1b8061a0,1024,0}, 34)
2020/06/22 04:34:56 socat[4087427] D recvmsg(, {AF=17 AF=17 0x00040200000001000006f832e4c0,20,,1,,0,}, ) -> 60
2020/06/22 04:34:56 socat[4087427] I permitting packet from AF=17 AF=17 0x00040200000001000006f832e4c0
2020/06/22 04:34:56 socat[4087427] D recvfrom(5, 0x5649e4b121a0, 2048, 0, 0x7ffc1b805f30, 112)
2020/06/22 04:34:56 socat[4087427] D recvfrom(,,,, {17,AF=17 AF=17 0x00040200000001000006f832e4c0}, 20) -> 60
2020/06/22 04:34:56 socat[4087427] N received packet with 60 bytes from AF=17 AF=17 0x00040200000001000006f832e4c0
> 2020/06/22 04:34:56.302108 length=60 from=0 to=59
3c 97 0e 1d 3f 07 f8 32 e4 c0 48 ab 00 02 61 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
2020/06/22 04:34:56 socat[4087427] D write(6, 0x5649e4b121a0, 60)
2020/06/22 04:34:56 socat[4087427] D write -> 60
2020/06/22 04:34:56 socat[4087427] I transferred 60 bytes from 5 to 6
2020/06/22 04:34:56 socat[4087427] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:34:56 socat[4087427] D select(7, &0x60, &0x40, &0x0, NULL/0.000000)
2020/06/22 04:34:56 socat[4087427] D select -> (, 0x0, 0x40, 0x0, NULL/0.000000), 1
2020/06/22 04:34:56 socat[4087427] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:34:56 socat[4087427] D select(7, &0x60, &0x0, &0x0, NULL/0.000000)
f832e4c048ab3c970e1d3f07000461626162 at /home/stefan/perly line 21.
2020/06/22 04:34:56 socat[4087427] D select -> (, 0x40, 0x0, 0x0, NULL/0.000000), 1
2020/06/22 04:34:56 socat[4087427] D read(6, 0x5649e4b121a0, 2048)
2020/06/22 04:34:56 socat[4087427] D read -> 18
< 2020/06/22 04:34:56.315801 length=18 from=0 to=17
f8 32 e4 c0 48 ab 3c 97 0e 1d 3f 07 00 04 61 62 61 62
2020/06/22 04:34:56 socat[4087427] D sendto(5, 0x5649e4b121a0[f832e4c0...], 18, 0, {AF=17 AF=17 0x00040200000001000006f832e4c0}, 20)
2020/06/22 04:34:56 socat[4087427] D sendto() -> 18
2020/06/22 04:34:56 socat[4087427] D getsockname(5, 0x7ffc1b806430, 0x7ffc1b80642c{112})
2020/06/22 04:34:56 socat[4087427] D getsockname(, {AF=17 AF=17 0x000402000000010000063c970e1d}, {18}) -> 0
2020/06/22 04:34:56 socat[4087427] N local address: AF=17 AF=17 0x000402000000010000063c970e1d
2020/06/22 04:34:56 socat[4087427] I transferred 18 bytes from 6 to 5
2020/06/22 04:34:56 socat[4087427] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:34:56 socat[4087427] D select(7, &0x60, &0x20, &0x0, NULL/0.000000)
2020/06/22 04:34:56 socat[4087427] D select -> (, 0x0, 0x20, 0x0, NULL/0.000000), 1
2020/06/22 04:34:56 socat[4087427] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:34:56 socat[4087427] D select(7, &0x60, &0x0, &0x0, NULL/0.000000)
2020/06/22 04:35:07 socat[4087427] D select -> (, 0x20, 0x0, 0x0, NULL/0.000000), 1
2020/06/22 04:35:07 socat[4087427] I socket_init(): unknown address family 17
2020/06/22 04:35:07 socat[4087427] D recvmsg(5, 0x7ffc1b805ef0{0x7ffc1b805f30,112,0x7ffc1b805ea0,1,0x7ffc1b8061a0,1024,0}, 34)
2020/06/22 04:35:07 socat[4087427] D recvmsg(, {AF=17 AF=17 0x00040200000001000006f832e4c0,20,,1,,0,}, ) -> 60
2020/06/22 04:35:07 socat[4087427] I permitting packet from AF=17 AF=17 0x00040200000001000006f832e4c0
2020/06/22 04:35:07 socat[4087427] D recvfrom(5, 0x5649e4b121a0, 2048, 0, 0x7ffc1b805f30, 112)
2020/06/22 04:35:07 socat[4087427] D recvfrom(,,,, {17,AF=17 AF=17 0x00040200000001000006f832e4c0}, 20) -> 60
2020/06/22 04:35:07 socat[4087427] N received packet with 60 bytes from AF=17 AF=17 0x00040200000001000006f832e4c0
> 2020/06/22 04:35:07.643502 length=60 from=60 to=119
3c 97 0e 1d 3f 07 f8 32 e4 c0 48 ab 00 02 61 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
2020/06/22 04:35:07 socat[4087427] D write(6, 0x5649e4b121a0, 60)
2020/06/22 04:35:07 socat[4087427] D write -> 60
2020/06/22 04:35:07 socat[4087427] I transferred 60 bytes from 5 to 6
2020/06/22 04:35:07 socat[4087427] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:35:07 socat[4087427] D select(7, &0x60, &0x40, &0x0, NULL/0.000000)
2020/06/22 04:35:07 socat[4087427] D select -> (, 0x0, 0x40, 0x0, NULL/0.000000), 1
2020/06/22 04:35:07 socat[4087427] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:35:07 socat[4087427] D select(7, &0x60, &0x0, &0x0, NULL/0.000000)
f832e4c048ab3c970e1d3f07000441424142 at /home/stefan/perly line 21.
2020/06/22 04:35:07 socat[4087427] D select -> (, 0x40, 0x0, 0x0, NULL/0.000000), 1
2020/06/22 04:35:07 socat[4087427] D read(6, 0x5649e4b121a0, 2048)
2020/06/22 04:35:07 socat[4087427] D read -> 18
< 2020/06/22 04:35:07.644273 length=18 from=18 to=35
f8 32 e4 c0 48 ab 3c 97 0e 1d 3f 07 00 04 41 42 41 42
2020/06/22 04:35:07 socat[4087427] D sendto(5, 0x5649e4b121a0[f832e4c0...], 18, 0, {AF=17 AF=17 0x00040200000001000006f832e4c0}, 20)
2020/06/22 04:35:07 socat[4087427] D sendto() -> 18
2020/06/22 04:35:07 socat[4087427] D getsockname(5, 0x7ffc1b806430, 0x7ffc1b80642c{112})
2020/06/22 04:35:07 socat[4087427] D getsockname(, {AF=17 AF=17 0x000402000000010000063c970e1d}, {18}) -> 0
2020/06/22 04:35:07 socat[4087427] N local address: AF=17 AF=17 0x000402000000010000063c970e1d
2020/06/22 04:35:07 socat[4087427] I transferred 18 bytes from 6 to 5
2020/06/22 04:35:07 socat[4087427] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:35:07 socat[4087427] D select(7, &0x60, &0x20, &0x0, NULL/0.000000)
2020/06/22 04:35:07 socat[4087427] D select -> (, 0x0, 0x20, 0x0, NULL/0.000000), 1
2020/06/22 04:35:07 socat[4087427] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2020/06/22 04:35:07 socat[4087427] D select(7, &0x60, &0x0, &0x0, NULL/0.000000)
^C2020/06/22 04:35:13 socat[4087427] N socat_signal(): handling signal 2
2020/06/22 04:35:13 socat[4087427] N exiting on signal 2
2020/06/22 04:35:13 socat[4087427] N socat_signal(): finishing signal 2
2020/06/22 04:35:13 socat[4087427] N exit(130)
2020/06/22 04:35:13 socat[4087427] D starting xioexit()
2020/06/22 04:35:13 socat[4087427] D kill(4087792, 15)
2020/06/22 04:35:13 socat[4087427] D kill() -> 0
2020/06/22 04:35:13 socat[4087427] I shutdown(6, 2)
2020/06/22 04:35:13 socat[4087427] D shutdown() -> 0
2020/06/22 04:35:13 socat[4087427] D finished xioexit()
$ sudo tcpdump -i enp0s25 -XX -# -n -e '(ether src f8:32:e4:c0:48:ab and ether dst 3c:97:0e:1d:3f:07) or (ether dst f8:32:e4:c0:48:ab and ether src 3c:97:0e:1d:3f:07)'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp0s25, link-type EN10MB (Ethernet), capture size 262144 bytes
1 04:34:56.299863 f8:32:e4:c0:48:ab > 3c:97:0e:1d:3f:07, 802.3, length 2: LLC, dsap Unknown (0x60) Group, ssap Unknown (0x62) Command, ctrl 0x0000: Information, send seq 0, rcv seq 0, Flags [Command], length 46
0x0000: 3c97 0e1d 3f07 f832 e4c0 48ab 0002 6162 <...?..2..H...ab
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0030: 0000 0000 0000 0000 0000 0000 ............
2 04:34:56.315971 3c:97:0e:1d:3f:07 > f8:32:e4:c0:48:ab, 802.3, length 4: LLC, dsap Unknown (0x60) Group, ssap Unknown (0x62) Command, ctrl 0x6261: Supervisory, Receiver Ready, rcv seq 49, Flags [Command], length 4
0x0000: f832 e4c0 48ab 3c97 0e1d 3f07 0004 6162 .2..H.<...?...ab
0x0010: 6162 ab
3 04:35:07.643182 f8:32:e4:c0:48:ab > 3c:97:0e:1d:3f:07, 802.3, length 2: LLC, dsap Unknown (0x60) Group, ssap Unknown (0x62) Command, ctrl 0x0000: Information, send seq 0, rcv seq 0, Flags [Command], length 46
0x0000: 3c97 0e1d 3f07 f832 e4c0 48ab 0002 6162 <...?..2..H...ab
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0030: 0000 0000 0000 0000 0000 0000 ............
4 04:35:07.644448 3c:97:0e:1d:3f:07 > f8:32:e4:c0:48:ab, 802.3, length 4: LLC, dsap Unknown (0x40) Group, ssap STP (0x42) Command, ctrl 0x4241: Supervisory, Receiver Ready, rcv seq 33, Flags [Command], length 4
0x0000: f832 e4c0 48ab 3c97 0e1d 3f07 0004 4142 .2..H.<...?...AB
0x0010: 4142 AB
#!/bin/bash
# $ sudo tcpdump -i enp0s25 -XX -n -e -# ether dst 00:11:22:33:44:55 or ether src 55:44:33:22:11:00
# $ sudo socat -b 2048 -x -d -d -d SOCKET-RECVFROM:17:3:0:x0004x02000000x0000x00x00x0000000000000000 SYSTEM:/usr/bin/cat
# $ sudo tcpdump -i enp0s31f6 -XX -n -e -# ether dst 00:11:22:33:44:55 or ether src 55:44:33:22:11:00
# $ echo -n -e "\x00\x11\x22\x33\x44\x55\x55\x44\x33\x22\x11\x00\x00\x02\x68\x69" | sudo socat -v -d -d -d -d - SOCKET-SENDTO:17:3:0:x0004x02000000x0000x00x06x0011223344550000
# Usage: $ ./socat.sh -n enp0s31f6 -s 001122334455 -e aabb -m ccdd -b 0400 -c 0100
# \x00\x11\x22\x33\x44\x55\x00\x11\x22\x33\x44\x55\xaa\xbb\x00\x00\xcc\xdd\x04\x00\x01\x00\x62\x93\x7d\x64
# echo -n "\x00\x11\x22\x33\x44\x55\x00\x11\x22\x33\x44\x55\xaa\xbb\x00\x00\xcc\xdd\x04\x00\x01\x00\x62\x93\x7d\x64" | sudo socat - SOCKET-SENDTO:17:3:3:x0300x02000000x0000x00x06x0011223344550000
function tickify { printf '%b\n' $([ $# -ge 1 ] && echo "$@" || cat) | fold -w1 | sed "s/^/'/"; }
# $ tickify abcd
# 'a
# 'b
# 'c
# 'd
# $ echo abcd | tickify
# 'a
# 'b
# 'c
# 'd
function asciify { printf '%x\n' $([ $# -ge 1 ] && echo "$@" || cat); }
# $ asciify \'a \'b \'c
# 61
# 62
# 63
# $ echo \'a \'b \'c | asciify
# 61
# 62
# 63
function unfold { ([ -z "$1" ] && tr -d '\n' || tr '\n' "$1"); echo; }
# $ echo -e "a\nb\n" | unfold
# ab
# $ echo -e "a\nb\n" | unfold ' '
# a b
function rev-width { env W=$1 perl -p -E 'my $w = $ENV{W} || 1; $_=join("", reverse unpack("A$w" x (length($_) / $w), $_))."\n"'; }
# $ echo -e "abcd\nefgh" | rev-width
# dcba
# hgfe
# $ echo -e "abcd1234\nefgh5678" | rev-width 4
# 1234abcd
# 5678efgh
function printfp { printf ${1:-%s\\n} $(cat); }
function hexify { sed 's/^/0x/g'; }
function binify { sed 's/^/\\x/g'; }
# $ echo 061122334400 | fold -w2 | binify | unfold | fold -w4 | printfp '%b' | od -t x2 -N 6 -A n
# 1106 3322 0044
# $ echo 6162636465666768 | fold -w2 | binify | unfold | fold -w16 | rev-width 4 | unfold
# \x64\x63\x62\x61\x68\x67\x66\x65
# $ echo abcdefgh | tickify | asciify | binify | unfold | fold -w16 | rev-width 4 | unfold
# \x64\x63\x62\x61\x68\x67\x66\x65
function ascii2hexbytes { printf '%x\n' $(echo "$@" | fold -w1 | sed "s/^/'/") | fold -w2 | tr -d '\n'; echo; }
function hexbytes2binary { echo "$@" | sed 's/ //g' | fold -w2 | while read a; do echo -n "\x$a"; done; }
# $ hexbytes2binary $(printf '%x' $(printf '%b' $(hexbytes2binary 6162636465666768 | fold -w16) | fold -w4 | rev | fold -w1 | sed "s/^/'/"))
# \x64\x63\x62\x61\x68\x67\x66\x65
AF_PACKET=17
SOCK_RAW=3
ETH_P_ALL=3
dst="001122334455"
lab="0000"
while getopts Dn:i:d:s:e:l:m:b:c:p: name
do
case $name in
D)dry=1;;
n)inm=$OPTARG;;
i)idx=$OPTARG;;
d)dst=$OPTARG;;
s)src=$OPTARG;;
e)eth=$OPTARG;;
l)lab=$OPTARG;;
m)mid=$OPTARG;;
b)cnt=$OPTARG;;
c)cls=$OPTARG;;
p)pay=$OPTARG;;
*)echo "Invalid arg";;
esac
done
shift $(($OPTIND-1))
[ -z "$src" -a -n "$inm" ] && src=$(cat /sys/class/net/$inm/address | sed 's/://g')
[ -z "$idx" -a -n "$inm" ] && idx=$(printf '%08x\n' $(cat /sys/class/net/$inm/ifindex) | fold -w2 | tac | while read a; do echo -n "$a"; done)
[ -z "$dst" ] && { echo "missing -d dst"; exit; }
[ -z "$src" ] && { echo "missing -s src"; exit; }
[ -z "$eth" ] && { echo "missing -e ethtype"; exit; }
[ -z "$lab" ] && { echo "missing -l srclabel"; exit; }
[ -z "$mid" ] && { echo "missing -m msgid"; exit; }
[ -z "$cnt" ] && { echo "missing -b bytecount"; exit; }
[ -z "$cls" ] && { echo "missing -c class"; exit; }
d=$(echo $dst | fold -w2 | binify | unfold)
s=$(echo $src | fold -w2 | binify | unfold)
e=$(echo $eth | fold -w2 | binify | unfold)
l=$(echo $lab | fold -w2 | binify | unfold)
m=$(echo $mid | fold -w2 | binify | unfold)
b=$(echo $cnt | fold -w2 | binify | unfold)
c=$(echo $cls | fold -w2 | binify | unfold)
[ -n "$pay" ] && p=$(echo $pay | fold -w2 | binify | unfold)
ethhdr="$d$s$e"
msghdr="$l$m$b$c"
#crc=$(echo -n "$msghdr$p" | gzip -c | tail -c8 | od -t x4 -N 4 -A n | cut -b2- | fold -w2 | while read a; do echo -n "\x$a"; done)
crc=$(crc32 $(echo "$msghdr" | fold -w2 | hexify | unfold ' '
printf '%08x\n' $(crc32_string "$msghdr$p") | fold -w2 | binify | unfold)
echo "$ethhdr$msghdr$p$crc"
[ -z "$dry" ] && echo "echo -n \"$ethhdr$msghdr$p$crc\" | sudo socat - SOCKET-SENDTO:$AF_PACKET:$SOCK_RAW:$ETH_P_ALL:x0300x${idx}x0000x00x06x${dst}0000"
Server:
# socat -t 0.1 -lu -x UDP4-RECVFROM:25152,reuseaddr,bind=127.0.0.1 PIPE
> 2020/07/06 23:31:39.308971 length=32 from=0 to=31
4d 6f 6e 20 30 36 20 4a 75 6c 20 32 30 32 30 20 31 31 3a 33 31 3a 33 39 20 50 4d 20 43 44 54 0a
< 2020/07/06 23:31:39.309420 length=32 from=0 to=31
4d 6f 6e 20 30 36 20 4a 75 6c 20 32 30 32 30 20 31 31 3a 33 31 3a 33 39 20 50 4d 20 43 44 54 0a
Client:
# date | socat -t 0.1 -lu -x - SOCKET-SENDTO:2:2:17:x62407f000001x0000000000000000,bind=x6241x00000000x0000000000000000
> 2020/07/06 23:31:39.308390 length=32 from=0 to=31
4d 6f 6e 20 30 36 20 4a 75 6c 20 32 30 32 30 20 31 31 3a 33 31 3a 33 39 20 50 4d 20 43 44 54 0a
< 2020/07/06 23:31:39.309786 length=32 from=0 to=31
4d 6f 6e 20 30 36 20 4a 75 6c 20 32 30 32 30 20 31 31 3a 33 31 3a 33 39 20 50 4d 20 43 44 54 0a
Mon 06 Jul 2020 11:31:39 PM CDT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment