Autonomous Machines & Society.

2022-08-13
Force Pty Allocation When Spinning Up Tmux Over Ssh

1
2
kali -t tmux attach -t <target_session_name>

or:

1
2
kali -o RequestTTY=no tmux attach -t <target_session_name>

situation:

1
2
3
$ ssh 192.0.2.125 tmux attach
open terminal failed: not a terminal

The solution is to simply force pseudo-terminal allocation.

1
2
3
$ ssh -t 192.0.2.125 tmux attach
[...]

Define RequestTTY in OpenSSH SSH client configuration file to make this permanent.

1
2
3
4
$ cat ~/.ssh/config
Host 192.0.2.125
RequestTTY yes

Read More

2022-08-12
Automatic Cmcc Network Switching

the policy follows:

如何校园网免流?

kali, could you use some network card for sniffing while connecting to existing network? or could you automate the sniffing so that we don’t get bored?

could you extract some login default patterns/filters?

for macos and linux:

if modifier hotspot is present, connect to it.

otherwise if CMCC present, connect to it.

if CMCC fails after login attempts, try to connect with some paid network.

for modifier:

if CMCC present, connect to it.

if CMCC fails, try to connect with some paid network.

internet switch will be manually turned on, to save power.

Read More

2022-08-11
The Kali Command On Macos

debugging

when kali is off, this mac will go crazy and hang everything.

need to scan for kali existance on demand, not all the time.

developing

should we use p2p networks to speed up remote connections like n2n or tinc?

would it be interesting to run all our kali connectors ranged from vscode-ssh-connect, rclone mount and direct ssh connection via kali command dynamically by our kali discovery service, if we can reload the nginx daemon on demand.

using redis to store some daemon reported values.

how about we set the workding directory of redis-server to /tmp so that the dump.rdb file will never take space after reboot?

we need to know if this will successifully launch after reboot since /tmp may not exist by that time

default redis server port: 6379

install redis-server service:

1
2
easyd -w /tmp -l redis_server -- /opt/homebrew/bin/redis-server

first value is online.

next value is kali_ip.

using both value to determine whether to connect to kali or not, and the exact address.

Read More

2022-08-11
Ramfs On Macos, Linux And Windows

linux

simply use /dev/shm

the only difference is that ramfs on linux is unbounded while tmpfs is bounded

create bounded tmpfs:

1
2
mount -t tmpfs -o size=2g tmpfs /mnt/tmp

or yoy labor yourself to mount some additional ramfs:

1
2
mount -t ramfs -o size=2g ramfs /mnt/tmp

macos

/private/tmp is not ramdisk. it is just a directory cleared by startup.

ram-shell: A simple script to create a in-memory filesystem on macOS

RAM-backed filesystem mounter for Mac OS X

create and mount ramdisk:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh
ramfs_size_mb=2100
mount_point=/tmp/rdisk
mkramdisk() {
ramfs_size_sectors=$((${ramfs_size_mb}*1024*1024/512))
ramdisk_dev=`hdid -nomount ram://${ramfs_size_sectors}`
newfs_hfs -v 'ram disk' ${ramdisk_dev}
mkdir -p ${mount_point}
mount -o noatime -t hfs ${ramdisk_dev} ${mount_point}
echo "remove with:"
echo "umount ${mount_point}"
echo "diskutil eject ${ramdisk_dev}"
}

to replace /private/tmp with ramfs and registered as launchd service

calculate sector numbers by hand:

disk_size(MiB)* 1024KiB/MiB * 1024B/KiB / 512B/sector = #sectors

1
2
3
4
5
6
7
8
9
hdiutil attach -nomount ram://#sectors
#get returned value afterwards!
newfs_hfs -v 'Ramdisk' <returned_disk_device_id>
# maybe you should create apfs case sensitive instead?
#mount disk
mkdir -p ~/Ramdisk
# may change fs type accordingly when using apfs
mount -o noatime -t hfs <returned_disk_device_id> ~/Ramdisk

windows

a curated ramdisk software list

use third-party ramdisk tool like imdisk, eram with kernel driver installed, secure boot disabled (no uefi maybe?)

Read More

2022-08-11
NoRepeat flag in pyjom producer

no consecutive clip sequences have then same file source.

no identical clips in render sequence.

Read More

2022-08-11
Copy Symlink Itself To Change Pyjom'S Location, Install Easyd Services For Macos Local Pyjom Watchdog

1
2
3
cd /media/root/parrot
cp -R -P /media/root/help1/pyjom .

because of the qqChatBot task, pyjom on kali may be syncing too often. need to check the watchdog logs.

turned out it is the __pycache__ dirs to be blamed

disable all sync related services on macos for debug:

main issue happens after local vscode launched.

the issue is such that the proxy setting not right.

to debug the service:

1
2
sudo launchctl debug gui/501/pyjom_local_syncdog --stdout --stderr

1
2
3
4
5
6
# to be succint:
launchctl list | grep syncdog | awk '{print $1}' | xargs -I abc kill -s TERM abc
# instead of:
#launchctl list | grep pyjom_local_syncdog # to get process pid
#kill -s TERM <service_pid>

we need to add some code for it. consider adding something alike to that to kali?

1
2
3
os.environ["http_proxy"]="http://localhost:7930"
os.environ["https_proxy"]="http://localhost:7930"

1
2
3
4
5
6
7
8
9
10
11
launchctl stop gui/501/pyjom_local_watchdog;
launchctl kill TERM gui/501/pyjom_local_watchdog;
launchctl unload gui/501/pyjom_local_watchdog;
launchctl disable gui/501/pyjom_local_watchdog;
launchctl remove gui/501/pyjom_local_watchdog;
launchctl stop gui/501/pyjom_local_syncdog;
launchctl kill TERM gui/501/pyjom_local_syncdog;
launchctl unload gui/501/pyjom_local_syncdog;
launchctl disable gui/501/pyjom_local_syncdog;
launchctl remove gui/501/pyjom_local_syncdog

install macos pyjom watchdog (local):

1
2
easyd -l pyjom_local_watchdog -w /Users/jamesbrown/Desktop/works/sync_git_repos -- /usr/bin/python3 /Users/jamesbrown/Desktop/works/sync_git_repos/watchdog_macos.py

install macos pyjom syncdog (local):

1
2
easyd -l pyjom_local_syncdog -w /Users/jamesbrown/Desktop/works/sync_git_repos -- /usr/bin/python3 /Users/jamesbrown/Desktop/works/sync_git_repos/syncdog_macos.py

Read More

2022-08-11
Linux Fan Not Spinning, Gpu Fan Not Spinning

everytime the fucking machine restarts, it fails devastatingly.

the word: Giving the fans some time to reach full speed...

the script:

1
2
3
4
5
6
7
#!/usr/bin/expect
spawn pwmconfig
#expect "Giving the fans some time to reach full speed..."
expect "If you do not want to do this hit control-C now!!!"
send "\03"
expect eof

hope this shit works?

1
2
3
echo 255 | sudo tee /sys/class/hwmon/hwmon6/pwm3
echo 255 | sudo tee /sys/class/hwmon/hwmon6/pwm1

i have install something other than that. like i8kctl, some thermal controllers by intel (thermald)? but still gpu fan not spinning till now.

1
2
3
4
apt install -y lm-sensors fancontrol
sensors-detect
pwmconfig

already have cpu frequency under control by running temp_throttle.sh

notes: found controllers dell_smm-isa-0000

1
2
3
4
Found the following PWM controls:
hwmon6/pwm1 current value: 255
hwmon6/pwm3 current value: 255

Read More

2022-08-10
Python Suggest Binary File Name Extension

Detect media file corruption, Python suggest binary file name extension

to rule out those corrupted media files, or unplayable files. maybe simply by parsing these files is not enough, we need a dedicated file corruption detector.

to truncate these files and see errors produced by media readers. use text file with media file extension to test them.

Read More

2022-08-10
Time Machine Alternative For Linux/Windows

use test to check existance some manual created identity file to prove if the endpoint is connected

(really? does that check work for offline rclone samba drives?)


format the backup disk as xfs so we can do symlink on it (linux).


use flock (from util-linux) to prevent multiple backup instances from running.

alternative: run-one

1
2
3
4
sudo apt-add-repository ppa:run-one/ppa
sudo apt-get update
sudo apt-get install run-one


linux-timemachine supports windows, linux, macOS, using rsync as backend, can use hardlink to make backup management very easy. can delete previous backup without losing data. need external controller to make “circular” or to only keep most recent backups on disk.

curated list of alternative time machine for OSes other than macOS

timeshift gui backup/restore tool for linux

duplicity incremental backup can store backup into encrypted tar files and support IMAP protocol as remote file server

Read More

2022-08-10
Vim Session Restore

Read More