FTP Trashes My File!

Posted on 2004-11-10
Last Modified: 2013-12-25

I'm having a weird problem with a CGI script I'm trying to run on an Apache server.  The script runs fine on the server, but whatever I've tried doing to pull the file down trashes it completely.  The file is full of the source code which is surrounded by gibberish, mostly the symbols "^@".

Now before you give me the newbie answers, think about why this is a 200 point question.  I've been in web development for almost 10 years.  Yes, I'm downloading the file as ASCII.  I've pulled via ftp, sftp and I've ssh'd into the system and pushed it, and it still happens.  Thinking it was a Windows thing, I've tried keeping the entire file in a UNIX environment (well...OS X Unix, anyway) and nothing seems to work.  I can't pull it down without this corruption occurring.  

Can anyone think of something I might be missing?


Question by:Raydot
    LVL 5

    Expert Comment

    Cat file to display and check it isn't corrupted at all.
    Try to pack file with gzip and get it with ftp as binary file.

    LVL 48

    Accepted Solution

    On the server, try doing

    od -c scriptname

    This will show you if you have any unusual characters that you wouldn't normally see.
    LVL 51

    Expert Comment

    ^@  do mean that these are binry zeros?
    please check with od (as already suggested)
    LVL 3

    Author Comment

    Sorry, I can't check from home so y'all wont hear back from me until I return to work Monday....
    LVL 3

    Author Comment

    Oh wait, actually, two questions.  I actually did look at the file on the server and it looked exactly the same, so it's not something going on in transfer.  This leaves me to wonder how this thing can even run!  I unfortunately can't get a hold of the original developer since he's kind of an odd duck.

    1)  Is it possible (although it seems unlikely) that I'm dealing with a compiled file?
    2)  "od" is something I didn't think to do so thanks for that there a difference between "od" and "hexdump?"
    LVL 3

    Author Comment

    Good call Tintin, you helped me answer my own question.

    Once I od'd it I could see that the file is a compiled C file.  So, of course, I'll need the source code to make any modifications.  It was an easy thing to miss considering the fact that the bulk of the .cgi file comes up as HTML.

    Thanks for the help, everyone...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
    It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now