For my link archive: [Wayback/Archive] HTGWA: Create a ZFS RAIDZ1 zpool on a Raspberry Pi | Jeff Geerling
–jeroen
Posted by jpluimers on 2023/08/21
For my link archive: [Wayback/Archive] HTGWA: Create a ZFS RAIDZ1 zpool on a Raspberry Pi | Jeff Geerling
–jeroen
Posted in *nix, Power User, ZFS | Leave a Comment »
Posted by jpluimers on 2023/08/17
A while ago I wrote about Figuring out the open network connections for processes ran by python, which explained the TL;DR:
pidof python | tr " " "\n" | xargs -r -n 1 lsof -i -a -e /run/user/1001/gvfs -p
Now I needed thread information as well, so below two examples using ps and pstree. I won’t explain the pidof and xargs stuff here as that was already covered in the above blog-post and I found out that ps already has a built-in way to filter on process name.
The ps solution uses the H, -L or -T argument to show the threads:
Posted in *nix, *nix-tools, bash, Development, lsof, Power User, ps, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2023/07/26
TL;DR is at the bottom (;
5 days ago this exploit development got published: [Wayback/Archive] snowcra5h/CVE-2023-38408: CVE-2023-38408 Remote Code Execution in OpenSSH’s forwarded ssh-agent.
It is about [Wayback/Archive] NVD – CVE-2023-38408 which there at NIST isn’t rated (yet?), neither at [Wayback/Archive] CVE-2023-38408 : The PKCS#11 feature in ssh-agent in OpenSSH before 9.3p2 has an insufficiently trustworthy search path, leading to remot.
However at [Wayback/Archive] CVE-2023-38408- Red Hat Customer Portal it scores 7.3 and [Wayback/Archive] CVE-2023-38408 | SUSE it did get a rating of 7.5, so since I mainly use OpenSuSE I wondered what to do as the CVE is formulated densely at [Wayback/Archive] www.qualys.com/2023/07/19/cve-2023-38408/rce-openssh-forwarded-ssh-agent.txt: it mentions Alice, but no Bob or Mallory (see Alice and Bob – Wikipedia).
Luckily, others readly already did the fine reading and emphasised the important bits, especially at [Wayback/Archive] RCE Vulnerability in OpenSSH’s SSH-Agent Forwarding: CVE-2023-38408 (note that instead of Alex, they actually mean Alice)
“A system administrator (Alice) runs SSH-agent on her local workstation, connects to a remote server with ssh, and enables SSH-agent forwarding with the -A or ForwardAgent option, thus making her SSH-agent (which is running on her local workstation) reachable from the remote server.”
According to researchers from Qualys, a remote attacker who has control of the host, which Alex has connected to, can load (dlopen()) and immediately unload (dlclose()) any shared library in /usr/lib* on Alice’s workstation (via her forwarded SSH-agent if it is compiled with ENABLE_PKCS11, which is the default).
The vulnerability lies in how SSH-agent handles forwarded shared libraries. When SSH-agent is compiled with ENABLE_PKCS11 (the default configuration), it forwards shared libraries from the user’s local workstation to the remote server. These libraries are loaded (dlopen()) and immediately unloaded (dlclose()) on the user’s workstation. The problem arises because certain shared libraries have side effects when loaded and unloaded, which can be exploited by an attacker who gains access to the remote server where SSH-agent is forwarded to.
Mitigations for the SSH-Agent Forwarding RCE Vulnerability
Posted in *nix, *nix-tools, bash, bash, Communications Development, Development, Internet protocol suite, OpenSSH, Power User, PowerShell, Scripting, Security, Software Development, SSH | Leave a Comment »
Posted by jpluimers on 2023/07/11
pidof python | tr " " "\n" | xargs -r -n 1 lsof -i -a -e /run/user/1001/gvfs -p
Breakdown:
pgrep installed):# pidof python 26128 12583
xargs prefers line separated, lets replace spaces with newlines (I showed this before in Source: firewalld: show interfaces with their zone details and show zones in use):# pidof python | tr " " "\n" 26128 12583
xargs squashes all input on one line:# pidof python | tr " " "\n" | xargs echo 26128 12583
-L 1 or -n 1 argument to keep them on separate lines:# pidof python | tr " " "\n" | xargs -L 1 echo 26128 12583 # pidof python | tr " " "\n" | xargs -n 1 echo 26128 12583
lsof can not only show open files, but also IP sockets (-i), and *only* those (-a), for a specific process ID (-p #). So by having the -p as last argument, xargs will append the process ID after it:# pidof python | tr " " "\n" | xargs -n 1 lsof -i -a -p lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1001/gvfs Output information may be incomplete. lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1001/gvfs Output information may be incomplete. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME python 12583 jeroenp 7u IPv4 8347396 0t0 TCP 192.168.124.38:54576->192.168.124.23:1012 (ESTABLISHED) python 12583 jeroenp 8u IPv4 8345460 0t0 TCP 192.168.124.38:48250->192.168.124.23:http (CLOSE_WAIT)
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1001/gvfs is a warning not easy to workaround in a short manner as per [Wayback/Archive] privileges – lsof: WARNING: can’t stat() fuse.gvfsd-fuse file system – Unix & Linux Stack Exchange (thanks [Wayback/Archive] pabouk and [Wayback/Archive] jmunsch):In your case
lsofdoes not need to check the GVFS file systems so you can exclude thestat()calls on them using the-eoption (or you can just ignore the waring):lsof -e /run/user/1000/gvfs
(via: [Wayback/Archive] lsof: WARNING: can’t stat() fuse.gvfsd-fuse file system /run/user/1001/gvfs – Google Search)
So you get this:
# pidof python | tr " " "\n" | xargs -n 1 lsof -i -a -e /run/user/1001/gvfs -p COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME python 12583 jeroenp 7u IPv4 8347396 0t0 TCP 192.168.124.38:54576->192.168.124.23:1012 (ESTABLISHED) python 12583 jeroenp 8u IPv4 8345460 0t0 TCP 192.168.124.38:48250->192.168.124.23:http (CLOSE_WAIT)
lsof, and xargs has an argument just for that: -r, see my earlier post Source: -r argument to pipe (no argument for MacOS)- If no input is given to xargs, don’t let xargs run the utility – Unix & Linux Stack Exchange, so you get this# pidof python | tr " " "\n" | xargs -r -n 1 lsof -i -a -e /run/user/1001/gvfs -p
Via:
–jeroen
Posted in *nix, *nix-tools, bash, bash, Development, lsof, Power User, Scripting, Software Development, xargs | Leave a Comment »
Posted by jpluimers on 2023/06/20
[Wayback/Archive] ~mvforell/toluol – sourcehut git: Rust tool to make DNS queries
From [Archive] Max on Twitter: “@b0rk Shameless plug of an alternative to dig I’ve written: … It’s not complete yet (it can’t do what dig +trace does), but it’s getting there :) I’m also planning to add coloured output to make it more readable. …” / Twitter
In a reaction to [Archive] 🔎Julia Evans🔍 on Twitter: “I wish dig‘s output actually looked like this? I feel like there’s no reason (except compatibility or whatever) that it has to be as unreadable of it is …” / Twitter
Posted in *nix, *nix-tools, Development, dig, Power User, Rust, Software Development | Leave a Comment »
Posted by jpluimers on 2023/06/15
For my link archive some ISO links via [Wayback/Archive] openSUSE Leap 15.5 – Get openSUSE as I am steadily working my way back into IT and Software Development so I was anxious to see what has changed on this front. In the past I usually ran OpenSuSE Tumbleweed, but now I am going for OpenSuSE Leap versions that are stable for a longer period of time as per [Wayback/Archive] Lifetime – openSUSE Wiki
Leap Major Release (15.x) extends maintenance and support until a successor. At present, a successor has not been declared; Leap 15’s lifecycle fully aligns with SUSE Linux Enterprise. There is a projection as of March 2021 that Leap 15 will extend to Leap 15.5. The previous major version of Leap, 42, was supported for more than 36 months, while the current major version of Leap, 15, would then have up to 72 months of support (12×6).
Full DVD download for off-line installation:
Posted in *nix, LEAP, Linux, openSuSE, Power User, SuSE Linux | Leave a Comment »
Posted by jpluimers on 2023/04/20
Boy I wish threads with more than one person could be saved by the ThreadReaderApp.
Anyway:
[WayBack] Thread by @mipsytipsy: oh boy.. i was just idly musing over how the single most ubiquitous/useless metric is “CPU load average”, lol i wonder if you could use CPU…
oh boy.. i was just idly musing over how the single most ubiquitous/useless metric is “CPU load average”, lol
i wonder if you could use CPU load alerts to score how modern and powerful a team’s toolchain is, like a Waffle House Index for tooling. 🤔
…oh oh! but i was gonna say, this thread between @drk and @shelbyspees is a killer nanotutorial in how to ask better questions about your code — where to start, how to drill down and dig in, how to instrument, and how to approach such an open-ended exploratory jaunt. 👏🐝❤️it’s a really good illustration of this thing we end up saying all the time, which is “don’t fear the future, it is simpler and clearer and *easier* here! the way you are doing it NOW is the hard way!” 😖
time for cpu load average to go the way of the PC LOAD LETTER …
0:00/ 0:01
Posted in *nix, Cloud, Development, DevOps, Infrastructure, Power User, Software Development, Systems Architecture | Leave a Comment »
Posted by jpluimers on 2023/04/18
Cool one-liner program via [Archive] Jilles🏳️🌈 (@jilles_com) / Twitter:
for s in 0123456789ABCDEF 172.16.0.254 Passwd:admin;do echo -en "Big Endian: $s\nMiddle Endian: ";echo -n $s|xxd -e -g 4 | xxd -r;echo -en "\nLittle Endian: ";echo -n $s|xxd -e -g 2 | xxd -r;echo -en "\nReversed : ";echo -n $s|xxd -p -c1 | tac | xxd -p -r;echo -e "\n";done
Note that the hex are bytes, not nibbles, so the endianness is OK:
Big Endian: 0123456789ABCDEF Middle Endian: 32107654BA98FEDC Little Endian: 1032547698BADCFE Reversed : FEDCBA9876543210 Big Endian: 172.16.0.254 Middle Endian: .2710.61452. Little Endian: 71.2610.2.45 Reversed : 452.0.61.271 Big Endian: Passwd:admin Middle Endian: ssaPa:dwnimd Little Endian: aPssdwa:mdni Reversed : nimda:dwssaP
That nibble/byte thing confused me at first (as I associate hexadecimal output with hex dumps, where each hexadecimal character represents a nibble)) so here are some interesting messages from the thread that Jilles_com started:
for s in 0123456789ABCDEF 172.16.0.254 Passwd:admin;do echo -en "Big Endian: $s\nMiddle Endian: ";echo -n $s|xxd -e -g 4 | xxd -r;echo -en "\nLittle Endian: ";echo -n $s|xxd -e -g 2 | xxd -r;echo -en "\nReversed : ";echo -n $s|xxd -p -c1 | tac | xxd -p -r;echo -e "\n";done …” / TwitterSome related man pages:
tac(1): concatenate/print files in reverse – Linux man pagexxd(1): make hexdump/do reverse – Linux man pageecho(1): line of text – Linux man pagefor(1): perform set of commands multiple times – Linux man pageman(1): format/display on-line manual pages – Linux man page–jeroen
Posted in *nix, *nix-tools, bash, Development, Power User, Scripting, Software Development, xxd | Leave a Comment »
Posted by jpluimers on 2023/03/28
While writing On my reading list: Windows Console and PTY, I found out that OpenSSH had become available as an optional Windows feature.
It was in [Wayback/Archive.is] Windows Command-Line: Introducing the Windows Pseudo Console (ConPTY) | Windows Command Line:
Thankfully, OpenSSH was recently ported to Windows and added as a Windows 10 optional feature. PowerShell Core has also adopted ssh as one of its supported PowerShell Core Remoting protocols.
Here are a few links:
Posted in *nix, *nix-tools, Communications Development, ConPTY, Console (command prompt window), Development, Internet protocol suite, OpenSSH, Power User, SSH, ssh/sshd, TCP, Windows, Windows 10, Windows 11 | Leave a Comment »
Posted by jpluimers on 2023/03/16
PolyShell is a script that’s simultaneously valid in Bash, Windows Batch, and PowerShell (i.e. a polyglot).
[Wayback/Archive] llamasoft/polyshell: A Bash/Batch/PowerShell polyglot!
Need to check this out, as often I have scripts that have to go from one language to the other or vice versa.
Maybe it enables one language to bootstrap functionality in the other?
The above polyglot started with a quest to see if I can could include some PowerShell statements in a batch file with two goals:
cmd.exe command prompt, then have it start PowerShell with the same command-line argumentsThe reasoning is simple:
cmd.exe or PowerShell are runningLots of users still live in the cmd.exe world, but PowerShell scripts are way more powerful, and since PowerShell is integrated in Windows since version 7, so having a batch file bootstrap PowerShell still makes sense.
Since my guess was about quoting parameters the right way, my initial search for the link below was [Wayback/Archive] powershell execute statement from batch file quoting – Google Search.
I have dug not yet into this, so there are still…
These should give me a good idea how to implement a polyglot batch file/PowerShell script.
dosps2.cmd:@findstr/v "^@f.*&" "%~f0"|powershell -&goto:eof
Write-Output "Hello World"
Write-Output "Hello some@com & again"
@f and including an & and passes everything else to PowerShell.C:\tmp>dosps2
Hello World
Hello some@com & again
but the second answer got me in the below polyglot search query
@@:: This prolog allows a PowerShell script to be embedded in a .CMD file.
@@:: Any non-PowerShell content must be preceeded by "@@"
@@setlocal
@@set POWERSHELL_BAT_ARGS=%*
@@if defined POWERSHELL_BAT_ARGS set POWERSHELL_BAT_ARGS=%POWERSHELL_BAT_ARGS:"=\"%
@@PowerShell -Command Invoke-Expression $('$args=@(^&{$args} %POWERSHELL_BAT_ARGS%);'+[String]::Join([char]10,$((Get-Content '%~f0') -notmatch '^^@@'))) & goto :EOF
@PowerShell -Command Invoke-Expression $('$args=@(^&{$args} %*);'+[String]::Join([char]10,(Get-Content '%~f0') -notmatch '^^@PowerShell.*EOF$')) & goto :EOF
…
There are quite a few quirks that were leveraged or had to be worked around:
- All three languages have different escape characters:
- Bash: backslash (
\)- Batch: caret (
^)- PowerShell: backtick (
`)- Escape characters work inside Bash and PowerShell strings, but not batch strings.
- Redirects (i.e.
<and>) have special meaning in all three languages unless quoted.- Redirects don’t have to be at the end of a command.
- This is valid Bash/Batch/PowerShell:
echo >output.txt "Hello World"- Batch is the only language without multi-line strings or comments.
- Batch treats
>as a redirect even when it directly touches a string, but PowerShell doesn’t.- Batch script
GOTOstatements only work when run as a script, not when run interactively.- PowerShell’s multi-line comment (
<#) must be immediately preceded by whitespace.- Bash’s here documents may begin anywhere so long as it’s unquoted and not a comment.
…
It also pointed me to the above repository on GitHub, so lets include it here as well:
cmd.exe prompt, and it hides that prompt after finishing. Need to figure out why, and if it can be prevented or undone.hideWindow $script:cmdPid # Prevent user from closing command prompt
Powerglot encodes several kind of scripts using polyglots, for example, offensive powershell scripts. It is not needed a loader to run the payload.
It basically is a Python script that allows you to generate a polyglot from multiple separate scripts.
iex, aka [Wayback/Archive] Invoke-Expression (Microsoft.PowerShell.Utility) – PowerShell | Microsoft Docs)
–jeroen
Posted in *nix, *nix-tools, bash, bash, Batch-Files, Development, JavaScript/ECMAScript, Perl, Polyglot, Power User, PowerShell, Scripting, Software Development | Leave a Comment »