0
buf = "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80";

Given this shellcode string (just an example), I would like to split into multiple chunks of nth size.

Once its been split, given unknown nth number of chunks, i would then like it to automatically perform an fuction such as

os.system("echo " + chunk[1] + ">>/tmp/final")
os.system("echo " + chunk[2] + ">>/tmp/final")

but, without specifying each action each time, and not knowing the number of chunks that its been split into

walkamile
  • 23
  • 7
  • are you planning to encode and decode it into bytearray, or do you just want to divide the string at every n characters? – v.coder Sep 25 '17 at 15:44
  • Just want to divide the string at every nth character, then have complete an action with how ever many unknown chunks repeatedly, as my example. – walkamile Sep 26 '17 at 18:53
  • 1
    This is a nice way: https://stackoverflow.com/a/9475538/15890 – Tom Viner Sep 26 '17 at 19:03

1 Answers1

1

See if the below code helps you, it divides the string at every nth character:

nbuf = [buf[i:i+n] for i in range(0, len(buf), n)]
for st in nbuf:
    cmdk = 'os.system("echo "' + st + '">>/tmp/final")'
    subprocess.call(cmdk,shell=True)
v.coder
  • 1,822
  • 2
  • 15
  • 24