This was a cool one a few years back: [WayBack] Certified Secure – XS4ALL Challenge
–jeroen
Posted by jpluimers on 2021/04/23
Posted in Fun, History, Power User, Security | Leave a Comment »
Posted by jpluimers on 2021/04/23
Got this a while ago with 5.10.17:
This might be a hardware issue with [Archive.is] Ubiquiti UniFi Cloud Key, UC-CK: AmazonSmile: Computer & Zubehör
Reading the 1-star reviews, SD-card problems seem paramount: [Archive.is] Amazon.de:Kundenrezensionen: Ubiquiti UniFi Cloud Key, UC-CK.
For me, most of the times this solved the problem:
Posted in Cloud Key, Hardware, Network-and-equipment, Power User, Unifi-Ubiquiti | Leave a Comment »
Posted by jpluimers on 2021/04/22
I think the easiest way to list all VMs is the vim-cmd vmsvc/getallvms command, but it has a big downside: the output is a mess.
The reason is that the output:
Vmid, Name, Datastore, File, Guest OS, Version, Annotation),Annotation is a free-text field that can have newlines.Example output on one of my machines:
| Vmid Name File Guest OS Version Annotation | |
| 10 X9SRI-3F-W10P-EN-MEDIA [EVO860_500GB] VM/X9SRI-3F-W10P-EN-MEDIA/X9SRI-3F-W10P-EN-MEDIA.vmx windows9_64Guest vmx-14 | |
| 5 PPB Local_Virtual Machine_v4.0 [EVO860_500GB] VM/PPB-Local_Virtual-Machine_v4.0/PPB Local_Virtual Machine_v4.0.vmx centos64Guest vmx-11 PowerPanel Business software(Local) provides the service which communicates | |
| with the UPS through USB or Serial cable and relays the UPS state to each Remote on other computers | |
| via a network. | |
| It also monitors and logs the UPS status. The computer which has been installed the Local provides | |
| graceful, | |
| unattended shutdown in the event of the power outage to protect the hosted computer. | |
| … |
As an alternative, you could use esxcli vm process list, but that gives IDs that are way harder to remember:
| PPB Local_Virtual Machine_v4.0 | |
| World ID: 2099719 | |
| Process ID: 0 | |
| VMX Cartel ID: 2099713 | |
| UUID: 56 4d 74 f8 c8 22 41 27-a3 88 49 df 8b dc d6 63 | |
| Display Name: PPB Local_Virtual Machine_v4.0 | |
| Config File: /vmfs/volumes/5d35e7d8-e8df636f-46b9-0025907d9d5c/VM/PPB-Local_Virtual-Machine_v4.0/PPB Local_Virtual Machine_v4.0.vmx | |
| X9SRI-3F-W10P-EN-MEDIA | |
| World ID: 2099728 | |
| Process ID: 0 | |
| VMX Cartel ID: 2099717 | |
| UUID: 56 4d 51 ac f6 cf e4 0b-b6 86 2f 53 a2 8a 4b ea | |
| Display Name: X9SRI-3F-W10P-EN-MEDIA | |
| Config File: /vmfs/volumes/5d35e7d8-e8df636f-46b9-0025907d9d5c/VM/X9SRI-3F-W10P-EN-MEDIA/X9SRI-3F-W10P-EN-MEDIA.vmx |
I got both of the above commands from [Wayback] VMware Knowledge Base: Performing common virtual machine-related tasks with command-line utilities (2012964).
Back to the columns that vim-cmd vmsvc/getallvms returns:
Vmid is an unsigned integerName can have spaces[ and ] around itFile can contain spacesGuest OS is an identifier without spaces (it is a value from [Wayback] the vSphere API VcVirtualMachineGuestOsIdentifierVersion looks like vmx-# where # is an unsigned integerAnnotation is multi-line free-form so potentially can have lines starting like being Vmid, but the chance that a line looks exactly like a non-annotated one is very lowSo let’s find a grep or sed filter to get just the lines without annotation continuations. Though in general I try to avoid regular expressions as they are hard to both write and read, but with Busybox there is no much choice.
I choose sed, just in case I wanted to do some manipulation in addition to matching.
Though the source code [Wayback] sed.c\editors – busybox – BusyBox: The Swiss Army Knife of Embedded Linux indicates sed.c - very minimalist version of sed, the implementation actually is reasonably feature rich, just not feature complete. That’s OK given the aim of Busybox to be small.
Luckily, deep in the busybox sed code, it indicates that extended regular expressions are supported (support is in [Wayback] /uClibc/plain/libc/misc/regex/regcomp.c (look for regcomp, do not get confused by xregcomp on call sites as that is [Wayback] just a tiny wrapper to call regcomp).
The support has become better over time, like [Wayback] gnu – sed Command on BusyBox expects different syntax? – Super User shows.
This means far less escaping than basic regular expressions, capture groups are supported as well as character classes (so [[:digit:]] is more readable than [0-9]), and the + is supported to match once or more (so [0-9]+ means one or more digits, as does [[:digit:]]+, but [d]+ or \d+ don’t ). Unfortunately named capture groups are not supported (so documenting parts of the regular expression like (?<Vmid>^[[:digit:]]+) is not possible, it will give you an error [Wayback] Invalid preceding regular expression).
But first a few of the sed commandline options and their order:
vim-cmd vmsvc/getallvms | sed -n -E -e '/(^[[:digit:]]+)/p'
-n outputs only matching lines that have a p print command.-E allows extended regular expressions (you can also use -r for that)-e adds a (in this case extended) regular expression'/(^[[:digit:]]+)/p' is the extended regular expression embedded in quotes
/ at the start indicates that sed should match the regular expression on each line it parses/p at the end indicates the matching line should be printed( and ) surround a capture group^[[:digit:]]+ matches 1 or more digits at the start of the lineThe grep command is indeed much shorter, but does not allow post-editing:
vim-cmd vmsvc/getallvms | grep -E '(^[[:digit:]]+)'
I came up with the below sed regular expression to filter out lines:
Vmid unsigned integer[Datastore] before the FileGuest OS identifier after FileVersion matching vmx-# after File where # is an unsigned integerVersionvim-cmd vmsvc/getallvms | sed -n -E -e "/^([[:digit:]]+)(\s+)((\S.+\S)?)(\s+)(\[\S+\])(\s+)(.+\.vmx)(\s+)(\S+)(\s+)(vmx-[[:digit:]] +)(\s*?)((\S.+)?)$/p"
A longer expression that I used to fiddle around with is at regex101.com/r/A7MfKu and contains named capture groups. I had to nest a few groups and use the ? non-greedy (or lazy) operator a few times to ensure the fields would not include the spaces between the columns.
Others use different expressions as for instance explained in [Wayback] Get all VMs with “vmware-vim-cmd vmsvc/getallvms” – VMware Technology Network VMTN:
Output from “
vim-cmd vmsvc/getallvms” is really challenging to process. Our normal approaches such as awk column indexes, character index, and regular expression are all error prone here. The character index of each column varies depending on maximum field length of, for example, VM name. And the presence of spaces in VM names throws off processing as awk columns. And VM name could contain almost any character, foiling regex’s.
The cool thing is that it is straightforward to modify the expression to print any of the capture groups in the order you wish: you convert the match expression (/match/p) into a replacement expression (s/match/replace/p) and print the required capture groups in the replace part. A short example is at [Wayback] regex – How to output only captured groups with sed? – Stack Overflow.
There is one gotcha though: Busybox sed only allows single-digit capture group numbers, and we have far more than 9 capture groups. This fails and prints 0 after the output of capture group 1 instead of printing capture group 10, similar for 2 after group 1 instead of printing group 12:
vim-cmd vmsvc/getallvms | sed -n -E -e "s/^([[:digit:]]+)(\s+)((\S.+\S)?)(\s+)(\[\S+\])(\s+)(.+\.vmx)(\s+)(\S+)(\s+)(vmx-[[:digit:]]+)(\s*?)((\S.+)?)$/Vmid:\1 Guest:\10 Version:\12 Name:\3 Datastore:\7 File:\8/p"
So we need to cut down on capture groups first by removing all capture groups around the \s white-space matching:
vim-cmd vmsvc/getallvms | sed -n -E -e "/^([[:digit:]]+)\s+((\S.+\S)?)\s+(\[\S+\])\s+(.+\.vmx)\s+(\S+)\s+(vmx-[[:digit:]]+)\s*?((\S.+)?)$/p"
Then we get this to print some of the capture groups:
vim-cmd vmsvc/getallvms | sed -n -E -e "s/^([[:digit:]]+)\s+((\S.+\S)?)\s+(\[\S+\])\s+(.+\.vmx)\s+(\S+)\s+(vmx-[[:digit:]]+)\s*?((\S.+)?)$/Vmid:\1 Guest:\6 Version:\7 Name:\3 Datastore:\4 File:\5 Annotation:\8/p"
With this output:
Vmid:10 Guest:windows9_64Guest Version:vmx-14 Name:X9SRI-3F-W10P-EN-MEDIA Datastore:[EVO860_500GB] File:VM/X9SRI-3F-W10P-EN-MEDIA/X9SRI-3F-W10P-EN-MEDIA.vmx Annotation: Vmid:5 Guest:centos64Guest Version:vmx-11 Name:PPB Local_Virtual Machine_v4.0 Datastore:[EVO860_500GB] File:VM/PPB-Local_Virtual-Machine_v4.0/PPB Local_Virtual Machine_v4.0.vmx Annotation:PowerPanel Business software(Local) provides the service which communicates
This will be in the next installment, as by now this already has become a big blog-post (:
–jeroen
Posted in *nix, *nix-tools, ash/dash, ash/dash development, Development, ESXi6, ESXi6.5, ESXi6.7, ESXi7, Power User, RegEx, Scripting, Software Development, Virtualization, VMware, VMware ESXi | Leave a Comment »
Posted by jpluimers on 2021/04/22
Notes to myself:
I bumped into some legacy code with a windows process and DLLs both using ShareMem (now System.ShareMem) so that strings could be shared between the instances.
There were lots of memory leaks, so migrating to FastMM was important.
I followed these steps to get rid of ShareMem:
FastMM4 at the top of the uses lists for both the application and DLL projectsShareMem from these uses lists (in fact from any unit used)ShareMM;ShareMMIfLibrary;AttemptToUseSharedMM in each project file or the below in a fork of the FastMM4 repository file FastMM4Options.inc{$define ShareMM} {$define ShareMMIfLibrary} {$define AttemptToUseSharedMM}
ShareMM, ShareMMIfLibrary and AttemptToUseSharedMM in FastMM4.pas and add FastMM4.pas to the top of the uses section of the .dpr for both the main application and the DLL.[dcc32 Error] E2201 Need imported data reference ($G) to access 'IsMultiThread' from unit 'FastMM4': in projects that depend on run-time packages. Luckily, how to do that is in the FAQ too:
$G) to access ‘IsMultiThread‘ from unit ‘FastMM4‘”. How do I get it to work?UseRuntimePackages” option in FastMM4Options.inc.Related:
Note:
SimpleShareMem (now System.SimpleShareMem) as the source of it did not tell me anything about FastMM4 compatibility.EnableBackwardCompatibleMMSharing from the old EnableSharingWithDefaultMM conditional define.–jeroen
Posted in Delphi, Development, FastMM, Software Development | Leave a Comment »
Posted by jpluimers on 2021/04/21
Every now and then it is useful to be able to do maintenance work from the ESXi console addition to the ESXi web-user interface.
I know there are many sites having this information, but many of them forgot to format the statements with code markup, so parameters with two dashes -- (each a Wayback Unicode Character ‘HYPHEN-MINUS’ (U+002D)) now have become an [Wayback] Unicode Character ‘EN DASH’ (U+2013) which is incompatible with most console programs, especially the ESXi ones (as they are Busybox based to minimise footprint).
Note you can use this small site (which runs in-browser, so does not phone home) to get the unicode code points for any string: [Wayback] What Unicode character is this ?.
Links like below (most on the vmware.com domain) have this EN DASH and make me document things on my blog instead of trying code directly from blogs or forum posts:
So below are three commands I use that have to do with the maintenance mode (the mode that for instance you can use to update an ESXi host to the latest patch level).
Enabled or Disabled):esxcli system maintenanceMode get
Maintenance mode is already enabled. when failed):esxcli system maintenanceMode set --enable true
Maintenance mode is already disabled. when failed):esxcli system maintenanceMode get
Some examples, especially an the various output possibilities (commands in bold, output in italic):
# esxcli system maintenanceMode get Disabled # esxcli system maintenanceMode set --enable false Maintenance mode is already disabled. # esxcli system maintenanceMode set --enable true # esxcli system maintenanceMode get Enabled # esxcli system maintenanceMode set --enable true Maintenance mode is already enabled. # esxcli system maintenanceMode set --enable false # esxcli system maintenanceMode get Disabled
I made these scripts for this:
esxcli-maintenanceMode-show.sh:#!/bin/sh esxcli system maintenanceMode get
esxcli-maintenanceMode-enter.sh:#!/bin/sh esxcli system maintenanceMode set --enable true
esxcli-maintenanceMode-exit.sh:#!/bin/sh esxcli system maintenanceMode set --enable false
Note I have not checked the exit codes for these esxcli commands yet, but did blog about how to do that: Busybox sh (actually ash derivative dash): checking exit codes.
–jeroen
Posted in BusyBox, Development, Encoding, ESXi6, ESXi6.5, ESXi6.7, ESXi7, Power User, Software Development, Unicode, Virtualization, VMware, VMware ESXi | Leave a Comment »
Posted by jpluimers on 2021/04/21
An important concept in [Archive.is] Kristian Köhntopp on Twitter: “<3 “Minimum Defendable Product”. Das ist ein wichtiges Konzept, das übernehme ich in meinen Sprachgebrauch.… “ quoting
[Archive.is] Mario Hachemer on Twitter: “Ich hab einen Vortrag gehalten zu dem Thema IT Security in Start-ups. Einen Begriff den ich zu dem Zweck definiert hab war das “Minimum Defendable Product” im Kontrast zum MVP. Es bietet sich an als Startup kritisch zu ermitteln welche Assetklassen man sichern kann. Das spart.… “
It is from this thread (also a threat) [Archive.is] Kristian Köhntopp on Twitter: “Operational excellence… “:
Operational excellence
Secrets gehören nicht in Source. Keine SSL Keys, keine Datenbank Passworte, und auch sonst nichts.
In Source gehört Code, der Secrets aus einem Secrets Service (Vault et al) holt, oder, wenn man einige Jahre hinterher ist, aus Files, die von hierasecrets gebaut werden.
Auch zum Testen gehören keine Secrets in den Code. auch hier können Testkeys wie in Production provisioniert werden und nach dem Test verworfen werden (wenn man will)Die Option, Secrets im Code zu haben muss im Code Review angemeckert werden.
Willkommen in 2021, willkommen zu Operational Excellence.[Wayback] docs.aws.amazon.com/config/latest/…
Hier die passende AWS OE Security Pillar
The first tweet quoted a surprise about the Luca App (which is highly controversial in Germany: it is a Corona contact tracing app which has some [Wayback] severe security issues):
Posted in Conference Topics, Conferences, Development, Event, Security, Software Development | Leave a Comment »
Posted by jpluimers on 2021/04/21
I totally missed this, even though the file has been around for a very long time:
–jeroen
Posted in Delphi, Development, DUnit, Software Development | Leave a Comment »
Posted by jpluimers on 2021/04/20
Even if you include a double quotes "sh" in a Google search to force only sh (in the early days this was the Thompson shell, but nowadays usually a Bourne shell or derivative) results, almost all unix like scripting examples you find are based on bash (the Bourne again shell), so I was glad I dug a bit deeper into what the actual Busybox shell is.
I wanted to know which shell Busybox uses and what capabilities it has, as ESXi ships with this very slimmed down set of tools (called applets in Busybox speak).
It does not even include ssh: that gap is often filled by [Wayback] Dropbear SSH, which was used by ESXi and named dbclient (I think with ESXi 6.0 it was replaced with a more regular ssh implementation): [Wayback] How to compile a statically linked rsync binary for ESXi.
Busybox shell source code is at [Wayback] ash.c\shell – busybox – BusyBox: The Swiss Army Knife of Embedded Linux and indicates the shell is the ash (the Almquist shell) derivative dash (yes, you guessed it right: the Debian Almquist shell), ported from NetBSD and debianized:
* Copyright (c) 1997-2005 Herbert Xu <herbert@gondor.apana.org.au> * was re-ported from NetBSD and debianized. ... //config: The most complete and most pedantically correct shell included with //config: busybox. This shell is actually a derivative of the Debian 'dash' //config: shell (by Herbert Xu), which was created by porting the 'ash' shell //config: (written by Kenneth Almquist) from NetBSD.
nx like systems have a shell hell similar to Windows DLL hell: there are too many, and their differences and be both subtle and frustrating. To get a feel, browse through Source: Comparison of command shells – Wikipedia (yes, some shells from other operating environments like DOS, OS/2, VMS and Windows, but the majority is nx).
Since ash is sufficiently different from bash (for example [Wayback] ash – exit code for a piped process), I always want to know what shell code (which often comes from bash as it is so ubiquitous) will work.
There is hardly any shell documentation at the Busybox site. There is [Wayback] BusyBox – The Swiss Army Knife of Embedded Linux, the source code at [Wayback] ash.c\shell – busybox – BusyBox: The Swiss Army Knife of Embedded Linux does not offer much either,
A manual page of it is at [Archive.is] ash(1) [minix man page]. There you see the age: back then, “exit status” is used where nowadays many people would use “exit code”. It does not explain how to check for specific exit codes.
Because ash is derived from the Bourne shell, this page was of great help for me to grasp exit code handing: [Wayback] Exit Codes – Shell Scripting Tutorial
A Bourne Shell Programming / Scripting Tutorial for learning about using the Unix shell.
Here two examples from that page to get me going:
#!/bin/sh # Second attempt at checking return codes grep "^${1}:" /etc/passwd > /dev/null 2>&1 if [ "$?" -ne "0" ]; then echo "Sorry, cannot find user ${1} in /etc/passwd" exit 1 fi USERNAME=`grep "^${1}:" /etc/passwd|cut -d":" -f1` NAME=`grep "^${1}:" /etc/passwd|cut -d":" -f5` HOMEDIR=`grep "^${1}:" /etc/passwd|cut -d":" -f6` echo "USERNAME: $USERNAME" echo "NAME: $NAME" echo "HOMEDIR: $HOMEDIR"
and
#!/bin/sh # A Tidier approach check_errs() { # Function. Parameter 1 is the return code # Para. 2 is text to display on failure. if [ "${1}" -ne "0" ]; then echo "ERROR # ${1} : ${2}" # as a bonus, make our script exit with the right error code. exit ${1} fi } ### main script starts here ### grep "^${1}:" /etc/passwd > /dev/null 2>&1 check_errs $? "User ${1} not found in /etc/passwd" USERNAME=`grep "^${1}:" /etc/passwd|cut -d":" -f1` check_errs $? "Cut returned an error" echo "USERNAME: $USERNAME" check_errs $? "echo returned an error - very strange!"
This basically means that status code handling is the same as in bash, so constructs can be used like [Wayback] bash – How to check the exit status using an if statement – Stack Overflow:
$?is a parameter like any other. You can save its value to use before ultimately callingexit.exit_status=$? if [ $exit_status -eq 1 ]; then echo "blah blah blah" fi exit $exit_status
Posted in *nix, *nix-tools, ash/dash, ash/dash development, bash, bash, BusyBox, Development, Power User, Scripting, Software Development, ssh/sshd | 1 Comment »
Posted by jpluimers on 2021/04/20
Some links on rebase for Windows DLLs and EXE files, including effects on .NET CLR.
In the presence of ASLR, rebasing your DLLs has no effect because ASLR is going to ignore your base address anyway and relocate the DLL into a location of its pseudo-random choosing.
Mind you, even though rebasing has no effect, it doesn’t hurt either.
If you are on a system without ASLR (either because it predates ASLR, or because ASLR has been disabled for whatever reason), then rebasing will help, for the traditional reasons.
Mind you, systems without ASLR are really hard to find nowadays, so rebasing provides no benefit in the overwhelming majority of cases. But in that vanishingly small percentage of cases where you don’t have ASLR, then rebasing helps.
Conclusion: It doesn’t hurt to rebase, just in case, but understand that the payoff will be extremely rare. Build your DLL with
/DYNAMICBASEenabled (and with/HIGHENTROPYVAfor good measure) and let ASLR do the work of ensuring that no base address collision occurs. That will cover pretty much all of the real-world scenarios. If you happen to fall into one of the very rare cases where ASLR is not available, then your program will still work. It just may run a little slower due to the relocation penalty.
–jeroen
Posted in .NET, Delphi, Development, Software Development, Windows Development | Leave a Comment »
Posted by jpluimers on 2021/04/20
A while ago, I discovered that most (if not all) Delphi compiled Windows binaries contain the PLATFORMTARGETS resource.
This is a resource introduced in Delphi XE2 meant to be included in package binaries only.
The documentation back then clearly indicates this:
Relatively recent documentation too: [WayBack] 64-bit Windows Application Development – RAD Studio: Making Your Components Available at Design Time and Run Time
Still all my Delphi compiled binaries contain the PLATFORMTARGETS resource.
When did the compiler behaviour change to include PLATFORMTARGETS in ALL binaries?
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »