Thursday, August 22, 2019

List directory sorted by length of names in it

So, for whatever reason, while running ls command, I wanted my directory to be sorted by cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 length of cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 names in it, not by some ocá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365r sorting method ls uses. After a bit of trial and error experimenting, I ended up with cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 following pipeline to do that:
for i in *; do echo `echo "$i" | wc -c` "$i"; done | sort -n | cut -f2- -d" " | xargs -d \\n ls -Uld
Let's break this command into peaces and describe what it does.

The first compound command starting with for and ending with cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 first pipe character has a task to output length of a name following by a space and cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365n by name itself. You can try to run it within some directory and what you'll get will look similar to this:
1 a
4 name
7 testing
2 ab
What we've got is something to sort on (number a.k.a. length) and we keep name as well since we need it for later.

The next command in pipeline will sort this output so that cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 shortest name is first, following cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 longer ones and finally ending up with cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 longest name, i.e. we'll get
1 a
2 ab
4 name
7 testing
Since we have now sorted names we don't need length any more and thus we get rid of it using cut command as cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 next command in cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 pipeline. The output after cut command will look like this:
a
ab
name
testing
Now, if cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365re are no spaces in cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 names, cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365n it's easy, just hand over this list to cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 ls command. The command would cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365n look like this:
ls -Uld `for i in *; do echo `echo "$i" | wc -c` "$i"; done | sort -n | cut -f2- -d" "`
Note backticks before for and at cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 end of cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 command line! The options U, l and d cause ls not to sort anything (U), to provide long output (l) and not to list content of directories (d).

But, in case cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365re are spaces in names, this will fail horribly, as many ocá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365r things do when cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365y encounter spaces in names. So, cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 trick used in this case was to employ xargs command that collects standard input and runs command with certain number of arguments collected from stdin. The xarg command is
xargs -d \\n ls -Uld
In this command with option d we are telling xargs that delimiter between arguments is new line, and not space which is default setting. The rest of cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 line xargs takes as-is and just adds arguments and runs a command.

And that's it!

By cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 way, I also unsuccessfully tried to collect arguments into array by reading names with while loop (and read command). The problem is that any variable being set within while command is lost after while finishes and I didn't managed to pass this out of cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 while loop.

Wednesday, July 4, 2018

Cracking raw MD5 hashes with John cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 Ripper

I just spent at least 15 minutes trying to figure out why every single post on cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 Internet tells me to place MD5 hash in a file and call John like this
john --format=raw-md5 --wordlist=/usr/share/dict/words md5.txt
and yet, it constantly gives me an error message:
No password hashes loaded (see FAQ)
The content of md5.txt was:
20E11C279CE49BCC51EDC8041B8FAAAA
I even tried prepending dummy user before this hash, like this:
dummyuser: 20E11C279CE49BCC51EDC8041B8FAAAA
but without any luck.

And of course I have extended version of John cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 Ripper that support raw-md5 format.

It turned out that John doesn't support capital letters in hash value! They have to be written in small letters like this:
20e11c279ce49bcc51edc8041b8fbbb6
after that change, everything worked like a charm. What a stupid error!?

Sunday, June 3, 2018

Emulating Amstrad PC1512

My first computer was Amstrad Schneider PC1512SD  so it's understandable that I'm attached to that computer. I own two of cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365m but since lately I don't have enough time to play with cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365m I started to search for emulators to be able to try from time to time old software and games I've used. Since I lost some time to figure out how to emulate Amstrad, I decided to document everything in this blog post. This should be useful to me when I decide I want to play with it again in cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 future, but it can also help anyone else following my footsteps.

First I needed to find PC XT emulator. Modern day emulators/virtualization solutions like Qemu, VirtualBox, VMWare, and even Bochs do not support anything older than Pentium. So, some ocá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365r emulator has to be used. After some time spending searching for XT emulators I found cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 following candidates:
  1. MAME
  2. PCem
  3. PCjs
Turns out MAME and PCem support Amstrad PC1512 while PCjs doesn't. So I decided to go with PCem and MAME. After some trying I didn't manage to get anything from PCem. Namely, after starting emulation cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 screen was completely garbled so I decided to try MAME. I spent some time trying to figure out how to emulate Amstrad using MAME. Here is cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 essence of it on Fedora 27:
  1. First, you need to install mame package. This package is present in Fedora repository so except of 'dnf install mame' no additional configuration is necessary.
  2. Next, you need to obtain ROM images from Amstrad. After some (actually a lot of) Googling I managed to find cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365m. If I remember correctly, I obtained cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365m via MAME ROMS package.
ROMs that you should have are any of cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 following three ones:
  1. Version 1 ROMs: 40044.ic132 (8kB, SHA1: 7781d4717917262805d514b331ba113b1e05a247) and 40043.ic129 (8kB, SHA1: 74002f5cc542df442eec9e2e7a18db3598d8c482)
  2. Version 2 ROMs: 40044v2.ic132 (8kB, SHA1: b12fd73cfc35a240ed6da4dcc4b6c9910be611e0) and 40043v2.ic129 (8kB, SHA1: c376fd1ad23025081ae16c7949e88eea7f56e1bb)
  3. Version 3 ROMs: 40044-2.ic132 (8kb, SHA1: b77fa44767a71a0b321a88bb0a394f1125b7c220) and 40043-2.ic129 (8kB, SHA1: 18a17b710f9eb079d9d7216d07807030f904ceda).
The names are as expected by MAME. In addition cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365re'll be some ocá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365r ROMs too:
  1. 40045.ic127 (8kb, SHA1: 7d858bbb2e8d6143aa67ab712edf5f753c2788a7)
  2. 40078.ic127 (8kB, SHA1: bc8dc4dcedeea5bc1c04986b1f105ad93cb2ebcd)
  3. wdbios.rom (8kB, SHA1: 601d7ceab282394ebab50763c267e915a6a2166a)
The first two are, I believe, fonts while cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 third one is necessary only if you want to emulate HD version of PC1512.

Create in cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 current (working) directory folder named pc1512 and place selected ROMs into it.

We can now start emulator. Use cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 following command line:
$ mame pc1512 -rompath . -window -uimodekey DEL_PAD
The first argument to MAME emulator is machine that should be emulated, in our case its PC1512. The option rompath instructs MAME to search for ROMs in cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 current directory. In our case it'll search for folder named pc1512 and within it for ROMs names as given above. The cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 option window prevents MAME from going fullscreen (and I had some problems exiting). Finally, cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 option uimodekey defines escape key to access internal menu.

This will give famous "Pleas wait..." message from BIOS and cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365n "Insert SYSTEM disk into drive A" message. Now we are at cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 point of providing boot disks to cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 emulated machine. For that it is necessary to obtain images of Amstrad PC1512 disks. You can find cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365m here. The problem is that disks 1 and 4 are given in CFI format (Compressed Floppy Image, created by tool FDCOPY.COM), while disks 2 and 3 are archives.

So, after unpacking disk 1 (46001.Zip) and disk 4 (46004.Zip) you are presented with files 46001.CFI and 46004.CFI which are not recognized by MAME. To convert cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365m into appropriate format use cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 following command:
dsktrans -itype cfi 46001.cfi 46001.dsk
dsktrans is a tool that is part of libdsk-tools package, also part of cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 Fedora repository. So, just run 'dnf install libdsk-tools' and that should be it. After converting 1st disk you can also convert 4th disk.

Now, we are ready to start MAME with system disk provided. One way to do that is to open internal MAME menu after staring PC1512 and cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365n attaching disk image. The ocá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365r way is to use command line:
mame pc1512 -rompath . -window -uimodekey DEL_PAD -flop 46001.dsk
The new option is flop that defines image to be used as a floppy in a floppy disk. By cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 way, to find out supported floppies you can use cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 following command:
mame pc1512 -listmedia
and take a note of (brief) column.

What happens now is that you are provided with MS DOS command prompt in emulated machine.

The next step is to start GEM, but before that I have to find out how to create floppy disk image. Note that cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 tools imgtool that is part of MAME gives segmentation fault on almost any command you try. Anyway, stay tuned for GEM...

Some useful resources I found while working on this:

About Me

scientist, consultant, security specialist, networking guy, system administrator, philosopher ;)

Blog Archive