• 0

[C#] Best encryption method for ftp password


Question

I'm building a class that manages ftp connections. I just realized when making a private string for the password that anyone could just load the program in a hex program or something and grab the password can't they? Or aren't there ways to obtain that string? It seems kind of a bad idea to just have an ftp password sitting there in plain text. But I can do a one way encryption b/c I'd have no way of decrypting it for them. Any ideas to this solution? Or is it not even a problem if it's set to private?

8 answers to this question

Recommended Posts

  • 0

If you're using standard FTP the password isn't sent encrypted during authentication. If someone wanted it they could just sniff their own network traffic and read the plain text after your program has done whatever it is it needed to do in order de-obfuscate it.

  • 0
  G0NADS said:
if you wanted to keep someone from locally reading it, consider md5 hashing the password, it wont get sent encrypted and they could sniff it if theyw anted to, but if its md5'd in the proggy then its pretty secure

How do you propose turning that hash back into the source password so that it can be used when authenticating with the FTP server?

  • 0

Really the only way to not store the password in some readable form would be to have user interaction. In other words, have someone enter the password into a dialog box or something (obviously not what you want).

Here are some things you could do (none of which are fool-proof):

1) Encode the password locally with Base64 or something, then decode it when it needs to be sent to the FTP server. At least the password wouldn't be stored in plain sight.

2) Encrypt the password with AES locally and decrypt it before sending to the FTP server. This technically is no more secure then #1, because you'd have to store your AES key somewhere, which someone could read and then use to decrypt your FTP password.

3) Store the password in an encrypted database, such as SQLite. Again, same problem as above.

These methods all add steps that would prevent the casual person browsing your code or disassembling your program from seeing the plaintext password. But I think the bottom line is that in any system where someone has access to the machine running your code, the password could be compromised. It would be important to consider who has access to that code, and what their level of computer knowledge is. If it's a casual user, then the above methods should be fine. But if it's a knowledgeable programmer, I think you're out of luck.

Also, don't forget what "the evn show" said above: if you're using the plain FTP protocol, any ol' idiot can simply sniff the password from the network traffic, which would obviate the need to encrypt the password in your code.

  • 0
  Express said:
The recommended way is to use DPAPI

See http://msdn.microsoft.com/en-us/library/ms995355.aspx

Use ProtectedData class in System.Security.Cryptography if code is in .net

Thanks for pointing that out, but doesn't it inherently suffer from the same problem (that someone with access to the code could run the same protection routines to decrypt the password)?. Also, the protected FTP passwords could not be transferred to another machine because the ProtectedData class locks it to the current computer or user.
  • 0
  boogerjones said:
that someone with access to the code could run the same protection routines to decrypt the password

Only if someone knows your username & password+has access to your system. <= Equivalent to no password!

Just Code access doesn't give away your credentials.

  boogerjones said:
the protected FTP passwords could not be transferred to another machine because the ProtectedData class locks it to the current computer or user

I consider that as a plus point from a security perspective.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Guess I'll be saving the APK for future use, screw that data-harvesting copilot crap...
    • Looks like it, I have them working after the update.
    • MEmu Android Emulator 9.2.6 (offline installer) by Razvan Serea MEmu is a FREE Android emulator that brings fun of the Android experience to Microsoft Windows devices. It runs on nearly all Windows devices (PC, notebook, 2-in-1 devices, tablets). Comparing to other Android emulators, MEmu provides the highest performance and greatest compatibility. The richest features: Full Android experience with an elegant desktop Flexible customization (CPU#, memory size, resolution, device model, nav bar location, root mode, etc.) Mapping the keyboard / joystick to screen touch for much better game experience Passing through sensor data (e.g. accelerometer) to Android, so you can play car-racing like games intuitively GPS location simulation File sharing between Windows and Android Fast APK installation by drag and drop One-click Android system creation / clone / deleting, and you can run multiple Android instances simultaneously Using MEmu, you can: Have fun playing Android games on PC Chat more conveniently by using keyboard in Whatsapp, Wechat, etc. Watch live show and TV channels Ten seconds to start Directly open several Android Emulator windows MEmu Android Emulator 9.2.6 changelog: Optimized the emulator GUI to support native Windows 11 style. Optimized APK export speed, automatically export to shared directory, and display export progress. Fixed an issue where APK export could occasionally result in incomplete files on Android 12 instance. Fixed graphical corruption issues in Project Net game. Download: MEmu 9.2.6 Offline Installer | 639.0 MB (Freeware) View: MEmu Home Page | MEmu Support Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • You already have local admin rights. It is not really as bad as they say.
  • Recent Achievements

    • Week One Done
      Yawdee earned a badge
      Week One Done
    • Week One Done
      eugwalker earned a badge
      Week One Done
    • First Post
      Ben Gross earned a badge
      First Post
    • One Month Later
      chiptuning earned a badge
      One Month Later
    • Week One Done
      harveycoleman123 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      657
    2. 2
      +FloatingFatMan
      189
    3. 3
      ATLien_0
      146
    4. 4
      Xenon
      133
    5. 5
      wakjak
      107
  • Tell a friend

    Love Neowin? Tell a friend!