Basic information needed. Wanted a shellcode which when put in C code (like char buf[]={"<shellcode>"}) prints out "Hello World !". Is there a way to convert my plain English string "Hello World" in to shellcode.
Asked
Active
Viewed 411 times
-4
Chris
- 7,130
- 17
- 65
- 109
Aravind Kamble
- 11
- 1
- 3
-
What makes you think there _is_ such a thing? – John Saunders Jan 01 '15 at 15:00
-
1@JohnSaunders He might be new to programming in C, give him a break. There are ways to run shell scripts in c. Maybe not the exact way, but a lot of things are possible – Chris Jan 01 '15 at 15:15
-
2If you're running on Linux, see [this question](http://stackoverflow.com/q/15593214/1233508). If you're on Windows, see [this question](http://stackoverflow.com/q/4638960/1233508). Those are just starting points, you will probably need to tweak them and compile with specific flags to get them to work. If you get stuck, amend your question with specific details of what you have done and where you're having problems. – DCoder Jan 01 '15 at 15:27
1 Answers
-1
I don't think you can embed it directly in your code, but you can have a script as a separate file and call it from your program like this:
system("/path/to/script/myScript.sh");
This call is blocking, so your program will stay on this line until the script is complete. Then in myScript.sh you would have something like
#!/bin/sh
echo "Hello World!"
EDIT:
be sure to import <stdlib.h>
Chris
- 7,130
- 17
- 65
- 109
-
2Your answer covers *shell scripts*. The OP asked for *[tag:shellcode]*, which is a whole different beast. An example of shellcode can be seen in [this question](http://stackoverflow.com/q/23398915/1233508). – DCoder Jan 01 '15 at 15:22