Jump to content

Escaping " with \" in my shellcode is misplaced/replaces other char in my code

- - - - -

  • Please log in to reply
No replies to this topic

#1
Mentalbox

Mentalbox

    Newbie

  • Members
  • PipPip
  • 19 posts
Hi. I have a Patriot Office Box media player system that only has ash to script (I have access to it only through telnet, and it has a program called "ftpget" bundled with its "operative system" busybox). I'm a total newb in all languages, but more familiar in Perl, which I wrote a code that I believe should work, however the system doesn't have a Perl interpreter, so I've had to try write a shell script. Here's what I've got:
 #!/bin/ash count=1 while read line; do         ftpget -u $user -p $password $myip \"$count.mov\" \"$line\"; count=$         done < list.txt 
Of course $user, $password and $myip has actual values in the real code. The syntax for ftpget is: ftpget [options] remote-host local-file remote-file And the reason I enclose the local-file and remote-file with (")'s, is because the files I'm retrieving has spaces in them. The problem is: although the script does what it's supposed to if I only enclose once

Quote

ftpget -u $user -p $password $myip \"$count.mov\"; count=$
, it does not because I've enclosed two parameters (for some reason I can only enclose max 1).
I don't know why this happens, but the results are like this:

Quote

ftpget -u $user -p $password $myip "94.mov" "Somename/00.18"Conclusion/61025_18_01_SC11_outro.mov
The last enclosement (") has been moved away from the end of .mov"
And here's an example line of the text file used to be read from (list.txt):

Quote

Somename/00\.18\.Conclusion/61025\_18\_01\_SC11\_outro\.mov
I have also tried without escaping chars, that was the original, and then I've tried to escape all chars...
Help please :P

Edit: this forum still has a huge problem with editing -.-
When I edit a post, all newlines are removed. I have enabled ALL javascript...
I remember this was a problem on this forum about 2 years ago, lol.

Edit2: solved. Was the text file which had ^M's only visible in ******* Unix at the end of the file... And I can't automatically get rid of them as explained in various tutorials due to errors (missing packages blabla), so I gotta manually remove them. Thank you God for ******* up this motherfucking supposed-to-be-easiest-computer-task-in-the-world.

Edit3: not solved after all. The echo'd result (changing code to "echo ftpget ..." instead of just "ftpget") is correct, and if I manually copy it it is correct and the file will be downloaded. When I remove "echo", I get the default-syntax-output from ftpget again, and no connectivity with the FTP server.
WTF IS THIS!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?

Edit4: **** it. I did the manual work and downloaded each file individually. I'll rather **** Gates in the ass everyday by using a cracked version of Windows (as in free) than ever touching a ******* linux util again. (PS: for the FBI, SOPA-bastards, etc, I'm technically on a legit copy of Windows that came with the PC - I'm just making a point)

Edited by Mentalbox, 02 February 2012 - 07:55 AM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users