JMP script to automatically open Images - sas-jmp

I've a JMP file that contains a lot of information extracted from images. For example:
"Feature 1" "Feature 2" "Image FullPath"
1 2.1 "/myimage1path/myimagename1"
3 4.0 "/myimage2path/myimagename2"
When I analyze the features, I select some images of interest. I would like to automatically open the selected images.
To do so, I know that I have to create a JMP script. Can I do one of the following using JMP scripts?
Start an external program like GIMP/ImageJ and give the full path of all my images?
Call/launch a Python or Java program. In that case I know how to develop what I need with Python or Java, but I don't know how to call it from JMP script.

You will need to use the Run Program function from the JSL script.
Run Program Reference

Related

Can I use "no_caller_saved_registers" or "interrupt" attribute to write a task switching process?

Hi I'm a learner of x86_64 kernel and trying to follow a beginner book to write a simple one.
With the chapter of task switch, the author used assembly to push and pop the execution registers. However, I'm using newer gcc which do have the "no_caller_saved_registers" and "interrupt" option.
I tested the attribute, and somehow find out instead of pushing all registers, it will only save few of them according to the code within the function.
So I would like to ask that if I jmp or retq to switch task, would the compiler be smart enough to save all the related registers??
Thanks

Windows ASLR and address rewriting

I am just starting out learning about how code injection works and various defences.
I understand how and what ASLR does, but am struggling a little while looking at it in action.
By hijacking execution, I have added functionality (messagebox on startup) to mspaint.exe, calc.exe, and winword.exe. On WinXP these execute as desired. On Windows 7, the first two execute as desired but winword.exe runs into what I assume is ASLR:
[1] A call or jmp to an address in another executable section gets adjusted and executed properly.
[2] Similar instructions in that new section (call or jmp) are also adjusted properly
[3] Instructions to DLL APIs such as 'call LoadLibraryW', or simple memory access such as 'mov dword [esp], 40402d' do not get adjusted and so point to invalid address space.
Number [3] seems to happen even when I add these instructions directly to the .text section, right alongside an existing identical instruction that gets adjusted properly.
For example:
Using winword.exe, the instruction at 300010f0 is 'call [30001004]' (call GetProcAddress).
Running under ollydbg this shows it has been adjusted to 'call [04106b2f]'.
However, if I change the entrypoint instruction (300010cc) to be 'call [30001004]', this does not get adjusted at all.
Can someone explain or point me to some enlightenment as to the rules governing when and where instructions are adjusted like this? (or if I am being a complete numpty, a pointer towards some useful further reading would be appreciated)
Many thanks.

How to call library functions in shellcode

I want to generate shellcode using the following NASM code:
global _start
extern exit
section .text
_start:
xor rcx, rcx
or rcx, 10
call exit
The problem here is that I cannot use this because the address of exit function cannot be hard coded. So, how do I go about using library functions without having to re-implement them using system calls?
One way that I can think of, is to retrieve the address of exit function in a pre-processing program using GetProcAddress and substitute it in the shellcode at the appropriate place.
However, this method does not generate shellcode that can be run as it is. I'm sure there must be a better way to do it.
I am not an expert on writing shellcode, but you could try to find the import address table (IAT) of your target program and use the stored function pointers to call windows functions.
Note that you would be limited to the functions the target program uses.
Also you would have to let your shellcode calculate IAT's position relative to the process's base address due to relocations. Of course you could rely on Windows not relocating, but this might result in errors in a few cases.
Another issue is that you would have to find the target process's base address from outside.
A totally different attempt would be using syscalls, but they are really hard to use, not talking about the danger using them.
Information on PE file structure:
https://msdn.microsoft.com/en-us/library/ms809762.aspx

Assembly: What is the best way to print something to screen (to command line)

I've been doing some research, but I only find more and more ways to do what I want and I don't understand any of them.
What code do I need to assemble into an .exe to return 5 to the command line?
I want an exe that, when called, prints 5 .
Research:
printf "5", 0
It requires to link with 2 libraries, and I want to keep it simple.
move ebx, 5 ; or move ax, 5
ret
Why would this print 5 ? This loads a register whith a value 5 and returns. Nothing else.
Could someone explain me the difference between those ways of returning 5?
What would be most appropiate for a very simple Windows EXE executable?
I couldn't get the answers in the questions already asked in StackOverflow.
NOTE, I use: Win 7, WinAsam, MASM
THANKS!
Why not use printf? On windows, it is part of the MS C Runtime that is part of windows now.
Using the Windows API, you would use:
GetStdHandle
And one of the following:
WriteConsole
WriteConsoleOutput
WriteConsoleOutputAttribute
WriteConsoleOutputCharacter
WriteFile
All depends on how you want to do it.
moving something into a register does not print anything, you have to tell the OS to print it.
If you find something that you don't understand, do some research on it, read the documentation, code comments, play around with the code changing things and see how it works.

How to change screen background in assembler

This is for homework:
How do I clear the screen and change foreground and background colors in assembler (NASM on windows)
EDIT: It turns out the answer is something like
mov bh, 71h
int 10h
Check out FillConsoleOutputCharacter and SetConsoleTextAttribute.
You'll probably need some operating system services to get that kind of functionality. Since that's a requirement, how would you do it from another language? Once you figure that out, you can just make the same calls from your assembly language program. Something like:
call OSServiceClearScreen
where OSServiceClearScreen is the name of the system call or library function that performs the operation you want. Then just link your assembly program with the right libraries and it should all "just work".

Resources