How to determine the encoding of this dd image?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to determine the encoding of this dd image?
# 8  
Old 06-16-2014
I am not sure why you are using "cat" when strings strips all human readable text as standard:-

Code:
 strings /full/path/to/your/filename > /your/wanted/path/to/filename.txt

EDIT:-
Example:-
Code:
strings /bin/bash > /tmp/text


Last edited by wisecracker; 06-16-2014 at 02:20 PM.. Reason: See above...
This User Gave Thanks to wisecracker For This Post:
# 9  
Old 06-16-2014
How do you even know this is a mix of metadata and voice audio? Where did it come from? What were you told about it?
# 10  
Old 06-17-2014
I know exactly what there is inside the tape because I have the tape and its content on my disk.

However, the problem is that I have other 10 tapes that were produced with the some machine that needs to be decrypted.

The tape contains voice calls written by a voice recorder system. Each tape has more or less 80000 calls and its metadata associated.

The software that created the tape was written in Borland C++ and I have disassembled it with IDA. The software is unknown (I even couldn't find a guide on google) The software is too complicated to be disassembled in a reasonable amount of time but at least it gives me some tips and advice.
For instance, the tape was written with this function

Code:
HANDLE WINAPI CreateFile(   _In_      LPCTSTR lpFileName, 
                            _In_      DWORD dwDesiredAccess,   
                            _In_      DWORD dwShareMode,   
                            _In_opt_  LPSECURITY_ATTRIBUTES lpSecurityAttributes,   
                            _In_      DWORD dwCreationDisposition,  
                            _In_      DWORD dwFlagsAndAttributes,  
                            _In_opt_  HANDLE hTemplateFile 
);

Regarding the string conversion the procedure mentioned earlier does not work at all, except for the fact that it finds some name here and there within the file.

My initial question was very precise about converting the hexadecimal notation to a Big Endian.

if you copy and paste this code:

Code:
13 42 53 52 56 20 45 6C 65 6D 65 6E 74 20 48 65 61 64 65 72 00 00 00 00 00 00 00 00 10 00 00 00 10 00 00 00 41 00 00 00 55 F1 2E 04 A2 3F 32 01 32 38 FB 00 A2 3F 32 01 B7

to this website you will see that the conversion under UNIT 32 Big Endian is what I am looking for.

How can I do the same conversion in Linux Bash in order to convert my hexadecimal file (I know it is only a notation and the file is actually a binary file) to those number displayed under UNIT 32 Big Endian

Therefore, how can I do the following conversion in Bash:

Code:
54 00 00 00  -> 84        
A2 3F 32 01  -> 20070306

Thanks

Last edited by NICEPeppino; 07-30-2014 at 08:04 AM.. Reason: I tried to make my question clearer
# 11  
Old 06-19-2014
It certainly wasn't written to with that function. Opened, perhaps, written, no.

Code:
$ echo $((0x042ef155))
70185301
$

# 12  
Old 06-19-2014
Looking at your original post how do you get this???
Code:
//Hex Not.    // Little-Endian unsigned int 32
10 00 00 00   // 84       (Ref Number)  
54 00 00 00   // 70185301 (Ref Number)
55 F1 2E 04   // 20070306 (Date)
A2 3F 32 01   // 15144184 (Time)
F8 14 E7 00   // 20070306 (Date)
A2 3F 32 01   // 15491037 (Time)
DD 5F EC 00   // 1
01 00 00 00   // 1

It should be something like this:-
Code:
//Hex Not.    // Little-Endian unsigned int 32
10 00 00 00   // 16 ???
54 00 00 00   // 84       (Ref Number)  
55 F1 2E 04   // 70185301 (Ref Number)
A2 3F 32 04   // 20070306 (Date)
F8 14 E7 00   // 15144184 (Time)
A2 3F 32 01   // 20070306 (Date)
DD 5F EC 00   // 15491037 (Time)
01 00 00 00   // 1
01 00 00 00   // 1

This will work within limits but will probably be slow:-
Code:
#!/bin/bash
# Assuming longword aligned and data ONLY...
# Endian convert...
> /tmp/data
ifs_str="$IFS"
IFS=" "
arraytext=(13 42 53 52 56 20 45 6C 65 6D 65 6E 74 20 48 65 61 64 65 72 00 00 00 00 00 00 00 00 55 F1 2E 04 10 00 00 00 10 00 00 00 41 00 00 00 55 F1 2E 04 A2 3F 32 01 32 38 FB 00 A2 3F 32 01 B7)
n=0
while [ $n -lt ${#arraytext[@]} ]
do
	printf "\x${arraytext[$n]}" >> /tmp/data
	n=$((n+1))
done
hexdump -C < /tmp/data
echo "Start of decoding..."
# Assume data starts after 'BSRV Element Header' hard coded for this demo...
n=20
while [ $n -lt ${#arraytext[@]} ]
do
	hex=${arraytext[$((n+3))]}${arraytext[$((n+2))]}${arraytext[$((n+1))]}${arraytext[$n]}
	printf "%u\n" $((0x$hex))
	n=$((n+4))
done
echo "End of decoding..."
IFS="$ifs_str"
exit 0

Results on OSX 10.7.5, default bash terminal...
Code:
Last login: Thu Jun 19 21:21:16 on ttys000
AMIGA:barrywalker~> ./endian.sh
00000000  13 42 53 52 56 20 45 6c  65 6d 65 6e 74 20 48 65  |.BSRV Element He|
00000010  61 64 65 72 00 00 00 00  00 00 00 00 55 f1 2e 04  |ader........U...|
00000020  10 00 00 00 10 00 00 00  41 00 00 00 55 f1 2e 04  |........A...U...|
00000030  a2 3f 32 01 32 38 fb 00  a2 3f 32 01 b7           |.?2.28...?2..|
0000003d
Start of decoding...
0
0
70185301
16
16
65
70185301
20070306
16463922
20070306
183
End of decoding...
AMIGA:barrywalker~> _

This does NOT take into account any voice data that may be in the file...
These 2 Users Gave Thanks to wisecracker For This Post:
# 13  
Old 06-20-2014
Thanks, this is what I was looking for, You are THE MAN.

I need just a final tip but it is off-topic (so feel free to answer). I know the audio data in encoded in G729.
My question is, how this data should be modified before giving it as input to the G729 decoder?

Just swapping bits is enough?

Does ffmpeg or sox have an argument that swap bits automatically and convert them to wav?
# 14  
Old 06-20-2014
Hi...

I trust the Moderators will allow this...

I can't really answer your question definitively but a few pointers.

I was once told your best test gear is ears, eyes, nose, and throat so...

1) Assume the data is raw to start with.
2) Assuming that you are have OSS compatible, (Pulseaudio too?), /dev/dsp.
3) Feed the data into /dev/dsp something like...
Code:
cat /path/to/your/tape/data > /dev/dsp

The standard default /dev/dsp is:-
Sampling speed = 8KHz.
8 bit Unsigned integer depth.
RAW data.
MONO...
4) If your ears say this is dreadful then resort to SOX. This is seriously powerful so
thoroughly read the manual on it...
5) I have no idea whether the __audio__ on the tape is 8, 16, 24, 32 bit depth,
signed. unsigned, ULAW, ALAW, MONO/STEREO, etc, etc...
6) Assuming no kind of strange algorithm has been HW performed then an approximation
of sampling speed will be roughly your complete file-length divided by the number of
seconds duration _IF_ in MONO, 8 bit, unsigned mode which I suspect being a voice recorder it is.
(It is just as easy to work out sampling speed if the recording is in stereo too.)
Trial and error is your only method I am afraid...
7) After RAW start trying much older audio formats and come forwards to the latest
encodings...
Hope this helps...

EDIT:
Just noticed you mentioned G729 encoding.
The above still applies though, although RAW it probably is not... ;o)

Last edited by wisecracker; 06-20-2014 at 11:44 AM..
This User Gave Thanks to wisecracker For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

View file encoding then change encoding.

Hi all!! I´m using command file -i myfile.xml to validate XML file encoding, but it is just saying regular file . I´m expecting / looking an output as UTF8 or ANSI / ASCII Is there command to display the files encoding? Thank you! (2 Replies)
Discussion started by: mrreds
2 Replies

2. Shell Programming and Scripting

matching image files to create one image

Hi, I have two sets of image files. Both sets have names A to Z but set 1 ends with .cdt.png and set 2 ends with .matrix.png. I want set 1 to match with set 2 if the names match (i.e. A.cdt.png will match with A.matrix.png) and with the convert image tool (program for images), it will merge the... (6 Replies)
Discussion started by: kylle345
6 Replies

3. Solaris

Encoding problem

Hi All, Hope you can help me with the below :). I'm working on a script on SUN solaris and I'm facing a problem with the number encoding as shown below, 1 is encoded to 31 (this is ASCII so it's ok) 11 is encoded as B118 !!! don't know why 111 is encoded as B1580C !!! don't know why ... (4 Replies)
Discussion started by: /dev/bag
4 Replies

4. Shell Programming and Scripting

How to find the file encoding and updating the file encoding?

Hi, I am beginner to Unix. My requirement is to validate the encoding used in the incoming file(csv,txt).If it is encoded with UTF-8 format,then the file should remain as such otherwise i need to chnage the encoding to UTF-8. Please advice me how to proceed on this. (7 Replies)
Discussion started by: cnraja
7 Replies

5. Shell Programming and Scripting

UTF8 encoding

Hi experts, I have a gz file from other system(solaris), which is ftped to our system(solaris). After gunzip, the file is a xml file and we are using ORACLE built in xml transformiing tool ORAXSL to transform XML to TXT. Now the issue is we come accross issue regarding UTF8 as below:... (1 Reply)
Discussion started by: summer_cherry
1 Replies

6. UNIX for Dummies Questions & Answers

Encoding Type

Hi, Where can I find the encoding type in a unix server ? Thanks in advance !!! (1 Reply)
Discussion started by: risshanth
1 Replies

7. Shell Programming and Scripting

Araic Encoding

hi folks , I have a shell script which contain SQL query that dump some data from the DB in arabic and this data is written to a file in unix machine but the problem that the arabic data is appear like ??????????|111|???????? even when I move it to my windows XP machine. Any one have an Idea... (2 Replies)
Discussion started by: habuzahra
2 Replies

8. Shell Programming and Scripting

URL encoding

Hi All, I want to do URL encoding using shell script in my project. I decided that the sed is the correct tool to do this. But I am unable achieve what I wanted using sed. kindly help me to get rid of this. My requirement is , there will be one URL with all special character, spaces etc... ... (8 Replies)
Discussion started by: Vichu
8 Replies

9. UNIX for Dummies Questions & Answers

encoding

Hi, I'm using putty and when I try to write ü it writes | (or when I try to write é , it writes i) I tried to change settings/translation of putty but with no success I have KSH # locale LANG= LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" LC_COLLATE="C" LC_MONETARY="C" LC_MESSAGES="C"... (3 Replies)
Discussion started by: palmer18
3 Replies

10. UNIX for Advanced & Expert Users

Create an Ignite image on tape from Online IgniteUX image

Hi, (HP-UX 11.11) I need to create a tape image of an igniteUX image created on our igniteUX server. That is to say. I have a "Online" image of the igniteUX of the targeted system but I now need to copy it to a useable TAPE (igniteUX) image so i can build an other server from it that is not... (3 Replies)
Discussion started by: Andrek
3 Replies
Login or Register to Ask a Question