Miscellaneous about computing

TCP ports repartitions

  • Well-known ports (0 to 1023),
  • registered ports (1024 to 49151),
  • dynamic, private or ephemeral ports (49152 to 65535).

The Epeios related software uses ports 53700 to 53799.

  • xdhqxdh, for both incoming (FaaS) connections from the Atlas toolkit, and outgoing connections to to the Atlas toolkit: 53700,
  • xdhwebq: (incoming, from xdhq.php script): 53710,

Sharing 'Linux' folder to 'Windows'

Under 'Linux'

  • Install samba,
  • smbpasswd -a <username> (<username> seems to need to be an existing login, despite what can be found in some documentation),
  • add following section in /etc/samba/smb.conf :
[<name>]
path = /home/<user_name>/<folder>
available = yes
valid users = <username>
read only = no
browsable = yes
public = yes
writable = yes
  • relaunch samba (service smbd restart).

Under 'Windows'

In the file explorer, type \\<host>\<name> (<name> is the same name as the one given in the above section.

'ssh' on same server but different OSes

When you try to connect with ssh on a machine with more then one OS (a tablet which can be boot under Windows or Android, for example), ssh will complain, or even forbid the connection when you switch the target machine from one OS to another.

One solution is to share the same key between both OSes.

The other solution is to connect to one OS, then comment out the concerned line in the known_hosts file, the connect to the other OS, and finally uncomment the previously commented line in known_hosts. You can no connect to the 2 OS and ssh will no more complain.

nmap

  • To scan local network : nmap -sP 192.168.0.1/24;
  • ip a to obtain the IP to provide as parameter;
  • nmap -PS <IP>[/24] to retrieve the opened ports.

Dimensions of a SVG element

Function returning an array containing the x and y coordinate of the top left corner, the width and the height of the drawing area of a SVG of id id.

function svgViewBox( id ) {
 let x = 0;
 let y = 0;
 let width = 0;
 let height = 0;
 let svg = document.getElementById(id);
 let viewBox = svg.viewBox.baseVal;
 
 if ( viewBox !== null ) {
  x = viewBox.x;
  y = viewBox.y;
  width = viewBox.width;
  height = viewBox.height;
}
 
 if ( height === 0 ) {
  if ( width !== 0 )
   return "";
 } else if ( width === 0 ) 
  return ""
 
 if ( width === 0 ) {
  x = 0;
  y = 0;
  width = svg.width.baseVal.value;         
  height = svg.height.baseVal.value;         
 }
 
  return [x.toString(), y.toString(), width.toString(), height.toString()];
}

'restic'

restic is a backup software.

To refer to a repository, use -r <repository>, or the RESTIC_REPOSITORY environment variable (RESTIC_REPOSITORY=<repo>). Example: RESTIC_REPOSITORY=sftp:user@server:restic-repo restic ….

By default, restic will ask for the password. Using the RESTIC_PASSWORD environment variable to avoid this. Example RESTIC_PASSWORD=mypasswd restic ….

A restic repository can be accessed through a mountpoint under Linux (should also work under Windows with WSL) : restic -r <repo> mount <mountpoint>. The different snapshots are the located in <mountpoint>/snapshots.

'Kate'

Kate sometimes adds a new line at the end of a file, even if the file contents only one line. For example, type the a letter and save the file; the file will have a size of 2 bytes.
This behavior can be changed by unchecking Settings / Configuring Kate… / Editor Component / Open/Save / Automatic Cleanups on Save / Append newline at end of file on save.

Attaching a process to the debugger does not work (Linux)

https://stackoverflow.com/questions/19215177/how-to-solve-ptrace-operation-not-permitted-when-trying-to-attach-gdb-to-a-pro

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope or sudo bash -c “echo 0 > /proc/sys/kernel/yama/ptrace_scope.

Monitoring SSL/TLS certificate

To prevent a MITM attack on a SSL/TLS protected connexion (https://linuxfr.org/users/samuel/journaux/predator-files-surveillez-les-logs-certificate-transparency-sur-vos-domaines (fr)), certificate logs can be monitored through https://crt.sh/. Example: https://crt.sh/?q=linuxfr.org&deduplicate=Y.

Monitoring can be done through an ATOM feed. Example: https://crt.sh/atom?q=linuxfr.org&deduplicate=Y.