Is it possible to specify the output file path and let NASM decide the extension? - nasm

When I use NASM without specifying the output file, NASM decides the extension according to the output format.
For example, if I run NASM with output format "bin", it will create the output file with extension ".bin", if the output format is "win32", the extension is ".obj",...
Is it possible to specify the output file, and let NASM detect the output file extension according to the output format?

Related

Is it possible to get kernel version from ELF image file without disassemble or using grep or strings?

I have a vmlinuz ELF image file. I need to get the kernel version from the image file without disassembling it. Is it possible to get kerenel version from offsets of that compressed image file? The file is ELF 64-bit MSB executable, statically linked, not stripped.
As previously mentioned, the version number is hardcoded into the compressed image file. First it depends on the compression algorithm used to compress the content, how to decompress it.
Decompressing files in linux could be challenging due to the combination of compression algorithms and the correlated tool options (not to forget a newer version of tar for newer algorithms).
For files with
file extension tar.gz, tgz use e.g. $ tar -xzv -f vmlinuz.tgz
file extension tar.xz, use e.g. $ tar -xJv -f vmlinuz.tar.xz
file extension tar.bz2, use e.g. $ tar -xjv -f vmlinuz.tar.bz2
So if you have access to the file utility (should also run on windows), run the following to receive the version string and additional information of your file named e.g. vmlinuz-4.x.y-z-a.
file vmlinuz-4.x.y-z-a
Another possibility to reverse-engineer would be to read all strings of the binary file vmlinuz-4.x.y-z-a and grep for a part of the possible solution.
strings vmlinuz-4.x.y-z-a | grep 'linked,'

Converting pcapng file into csv file

I'm using Ubuntu terminal and I'm running using
tshark -r file.pcapng -T fields -e 6lowpan.src -e frame.proto >file.csv
I also can't get protocol info. I want to convert a .pcapng file into a .csv file.
But, I'm not able to retrieve 6 lowpan source address using 6lowpan.src. In the csv file i am getting empty file without any output and also I want the output data in text format.

don't understand the difference between "gcc -c file.c" and "gcc -o file.c" command

Command :
`gcc -c -Wall hello.c`
Here is the error : while calling ./hello.o
bash: ./hello.o: cannot execute binary file: Exec format error
need help please ..
.o is an object file, not an executable. It's an intermediate step. The -c option just says to make that step. You'll still have to link that object file into an executable.
These are the options you are asking for
-c
Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.
By default, the object file name for a source file is made by replacing the suffix ‘.c’, ‘.i’, ‘.s’, etc., with ‘.o’.
Unrecognized input files, not requiring compilation or assembly, are ignored.
-o file
Place output in file file. This applies to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code.
If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.
Using the first option you will have an object file, not an executable so you cannot execute it

Need more clarity on file command usage in linux?

I have built a linux image for ARM on Ubuntu. I was curious to use the file command on the image file created in arch/arm/boot directory. When i execute the following the command
balaji#balaji-virtual-machine:~/meraj/linux-stable/arch/arm/boot$ ls
bootp compressed dts Image install.sh Makefile zImage
balaji#balaji-virtual-machine:~/meraj/linux-stable/arch/arm/boot$ file Image
Image: data
balaji#balaji-virtual-machine:~/meraj/linux-stable/arch/arm/boot$ file zImage
zImage: data
balaji#balaji-virtual-machine:~/meraj/linux-stable/arch/arm/boot$
It gives not much information. I would like to know if this is expected behaviour or not?
From file manpage:
The type printed will usually contain one of the words...
... "data" meaning anything else (data is usually 'binary' or non-printable).
Exceptions are well-known file formats (core files, tar archives) that
are known to contain binary data.
Also...
Any file that cannot be identified as having been written in any of
the character sets listed above is simply said to be 'data'.

using GCC command prompt

gcc -std=c99 -DRAND -DPRNT -DTYPE=float -DBUBB *.c
I have this command line that we need to use in order to compile a program. The command creates a.out file. Now this is for bubble sorting purpose but a.out file generates random numbers but i would like to sort any numbers of my wish. May i know how to use command line to do that ? I am new to linux, do i need to associate any text file with a.out file ? If so how do i do that once a.out file is created ?
If I correctly understand you, your program generates random numbers, sorts them and then prints them out.
If you are interested in sorting, you can use Linux sort utility. To sort a text file you would do in the console:
sort text-file.txt
Or:
cat text-file.txt | sort
If you would like to make your own application sort any text file, change it to read the input from stdin and print the sorted output into stdout. Then invoke it the same way as sort above.

Resources