I haven't tried but isn't this automaticly? you declared i before and if eval() really just executes the string it should work. Or am i totaly false?
Hey guys, what's up??
I've been diving into executable protection and things like that and I find that I'm being limited by C++'s static linking ( I cannot modify the code while running)
Remember that little [TEST] thread of mine a while ago? I said I used techniques that would modify my code on the fly, it turned out that I was being tricked by my own program. There was nothing realy special about it.
I want to be able to change the way my program encrypts and thus decrypts itself every time it runs. I thought I had completed my objective but I was wrong...
Now I'm trying it again, and I want to do it like this:
I've read about a function called eval(), that exists in certain languages. The eval function would execute a string as code (!)
say this is an sample of a non-existant language:
The program would take the string "i = i + i" and execute it as code, so the echo function (which would be C++'s equvilant of printf()) would print: '2' to the screen.Code:var i = 1 echo( eval("i = i + i") )
Now before you get all excited about this, C++ doesn't support the eval() function.
I realy need such a function to complete my objective. And since there's nothing like this flying around the internets I'm going to code it myself
Does anyone have any experience with marco-languages and custom scripting? I alreay have a few basic ideas. But I've stumbled on a problem. How do I link strings to variable names?
Suppose I have a program like this:
How do I make the i in the string refer to the i in the program?Code:int i = 0; string str = "i = 2"; eval(str);
Is this even possible?
-SCHiM
I'm SCHiM
Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.
Polymorphic engine
Interprocess callback class
SIN
Infinite-precision arithmetic
Hooking dynamic linkage
(sloppy)Kernel mode Disassembler!!!
Semi debugger
I haven't tried but isn't this automaticly? you declared i before and if eval() really just executes the string it should work. Or am i totaly false?
_____________________________________________
READING TUTORIAL:
1. READ MY POST
2. THINK ABOUT MY POST
3. PRESS THANKS
4. MAYBE CORRECT MY POSTS :P
Dijkstra:
"Computer Science is no more about computers than astronomy is about
telescopes."
THANKS BUTTON RIGHT DOWN --->
I'm SCHiM
Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.
Polymorphic engine
Interprocess callback class
SIN
Infinite-precision arithmetic
Hooking dynamic linkage
(sloppy)Kernel mode Disassembler!!!
Semi debugger
Aaaa okay now it's clear for me that i was totaly wrong with my answer
but anyhow i didn't get 100% what you want.
EDIT:
ok you want to code "eval" by yourself but you have to know how to link the string i with the int i?
If yes I'm sorry I don't have a answer & I can't think about a way to do this But maybe others can =)
Last edited by doofbla; 09-26-2010 at 12:37 PM.
_____________________________________________
READING TUTORIAL:
1. READ MY POST
2. THINK ABOUT MY POST
3. PRESS THANKS
4. MAYBE CORRECT MY POSTS :P
Dijkstra:
"Computer Science is no more about computers than astronomy is about
telescopes."
THANKS BUTTON RIGHT DOWN --->
Hmm sadly I don't think this is possible. . . Well I tried to do some research on the matter and I came up with nothing but people saying various reasons why it would not work because of the paradigms C++ uses as a language.
Though good luck! This would definitely be interesting if you figure out a way.
if
i = 1
i+i=2
[php]printf("2");[/php]
1. Get input from user.
2. Split string using mathematical deliminators (+, -, =, *, /).
3. Convert each number into a unit (using atoi or a similar function)
4. Apply your mathematical operations
5. Output result.
I'm SCHiM
Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.
Polymorphic engine
Interprocess callback class
SIN
Infinite-precision arithmetic
Hooking dynamic linkage
(sloppy)Kernel mode Disassembler!!!
Semi debugger
I'm SCHiM
Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.
Polymorphic engine
Interprocess callback class
SIN
Infinite-precision arithmetic
Hooking dynamic linkage
(sloppy)Kernel mode Disassembler!!!
Semi debugger
I don't think even this will hide your string. Not to mention it seems really hard unless your damn good at macros. If you don't want people to see the string the string then the best option is to not include it in the program.
Do something like calculate the checksum of the string then store that in your program and calculate the checksum of the entered string on the fly. If the two match you have a correct answer.
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
No, that's not what I'm trying to do here... I'm trying to make it possible for C++ to selfmodify itself on the fly. That modification taking place in strings/code or otherwise. If I can get this done...
But it seems that my task is impossible (many others have failed where I will fail aswell)
I'm SCHiM
Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.
Polymorphic engine
Interprocess callback class
SIN
Infinite-precision arithmetic
Hooking dynamic linkage
(sloppy)Kernel mode Disassembler!!!
Semi debugger
I know that "good" spyware changes their code everytime they make a new copy of themself so maybe you should go a bit in that way to get information
(i hope you don't want to make such a tool)
EDIT: i just remembered the name :
POLYMORPHIC VIRUS/SPY-/MALEWARE or whatever...
just google "Polymorphism c++" and you'll find a lot of introductions and tutorials
Last edited by doofbla; 09-28-2010 at 11:47 AM.
_____________________________________________
READING TUTORIAL:
1. READ MY POST
2. THINK ABOUT MY POST
3. PRESS THANKS
4. MAYBE CORRECT MY POSTS :P
Dijkstra:
"Computer Science is no more about computers than astronomy is about
telescopes."
THANKS BUTTON RIGHT DOWN --->
First off. If your going for polymorphism I would implement it at the asm level, by taking certain instructions and changing them for equivalent instructions or instructions.
Secondly those people who failed were master virus programmers in many cases. A polymorphic self replicating virus seems a little out of your range. Why not try something simpler. Creating polymorphic code is possible, by changing inserting junkbytes in the code, but to actually change the executing instructions themselves is gonna take a lot of work.
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
To tell you guys the truth, I was fasinated by the idea of self-modifying code when I first started off writing code. And I never realy lost that fascination.
Although the technique is often used by polymorpic/ metamorphic viruses, and therefore seen as shady, if not mallicious. I think it can be used to create inreverceable exectutables (or atleast take the revercing of such .exe's to a whole new level)
@why
Dang, I knew it was comming for me...
*is of to learn asm, with an determination that will soon probably turn to dread by asm's daunting syntax*
@doofbla
The tutorials you're reffering to are about polymorphism in C++, which is different from writing self-modifying code
Last edited by .::SCHiM::.; 09-28-2010 at 01:16 PM.
I'm SCHiM
Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.
Polymorphic engine
Interprocess callback class
SIN
Infinite-precision arithmetic
Hooking dynamic linkage
(sloppy)Kernel mode Disassembler!!!
Semi debugger