Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Run Text Files as Executables

  1. #1
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Run Text Files as Executables

    Xav and I recently got into a discussion about how an Operating System interprets different file extensions. Hence, I thought it would be nice to show people how the operating system decides what to do with different types of files. To do so I wrote a small prog that will make an operating system interpret text files as executables an handle them in that manner. Using this method (no pun intended) one could potentially create viruses or other malicious files with a .txt extension. I will leave that up to everyone else. However, this should primarily serve as an educational prog. Here is the code...

    Code:
    /* Haxed Txt registry entry, runs .txt files like an executable
    ** To restore default enter this as the key 
    ** %SystemRoot%\system32\NOTEPAD.EXE %1
    */
    
    
    
    #include <windows.h>
    
    class Haxed_Txt {
          public:
                 void Change_Reg();
    };
    
    int main() {
        Haxed_Txt run_it;
        run_it.Change_Reg();
        
        return 0;
    }
    
    void Haxed_Txt::Change_Reg() {
         HKEY hKey;
         char data[500] = "\"%1\" %*";
         RegOpenKeyEx (HKEY_CLASSES_ROOT, 
                      "txtfile\\Shell\\Open\\Command",
                      0, 
                      KEY_SET_VALUE,
                      &hKey);
         
         RegSetValueEx (hKey,
                       "",
                       0,
                       REG_EXPAND_SZ,
                       (LPBYTE) data,
                       strlen(data) + 1);
         RegCloseKey (hKey);
    }
    Hope that helps someone out...

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Run Text Files as Executables

    Quote Originally Posted by MeTh0Dz View Post
    Xav and I recently got into a discussion about how an Operating System interprets different file extensions.
    Discussion? War, more like.

    Nice program, though. It could have gone in the tutorials section. +rep given.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  4. #3
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Re: Run Text Files as Executables

    Lol thanks...

  5. #4
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Run Text Files as Executables

    No sweat. Rep given where rep needs to be given.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  6. #5
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Run Text Files as Executables

    I'd like to point out that even though you can run a .txt file, only a real program with the .txt extension replacing the .exe extension will actually run. Anything else will give you an "Invalid Win32 Program" error.

  7. #6
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Re: Run Text Files as Executables

    DELETED

    Yeah, Slice Ownz Your Posts.

    Get over it

    /Talk
    Last edited by xXHalfSliceXx; 07-14-2008 at 07:27 PM.

  8. #7
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Run Text Files as Executables

    Hey, calm down Methodz. Dargueta is allowed to put forward a comment. Topics are allowed to be revived, as I believe the CC rules changed. Anyway, dargueta was just confirming that normal text files cannot be run as programs. I don't see any harm in that.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  9. #8
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Re: Run Text Files as Executables

    Okay who really is going to think that they can type some crap in a text document and then run it as an executable? That doesn't even come close to making any sense. Unless you are coding in binary that is (Yeah Right).

  10. #9
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Run Text Files as Executables

    I should have been more specific. But, if you want to get all puffed up about it...what about batch programs, VBS scripts...those can be "run" by the interpreter. It's easy enough to do, just change the open command to something like cscript %1. Double click on the file icon to open it, and it executes, even though it's plain text. There.
    Last edited by dargueta; 06-25-2008 at 03:25 PM.

  11. #10
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Re: Run Text Files as Executables

    Okay but you are changing the open command, so that makes your point null.

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help With Writing to Text files
    By teensicle in forum C and C++
    Replies: 5
    Last Post: 01-24-2010, 11:19 AM
  2. Need help extracting text from pdf files
    By Jumbala102 in forum Python
    Replies: 8
    Last Post: 04-12-2009, 07:38 AM
  3. Differences between text files and binary files.
    By LoneWolf in forum C and C++
    Replies: 3
    Last Post: 02-24-2009, 04:36 PM
  4. Text files
    By travy92 in forum Visual Basic Programming
    Replies: 1
    Last Post: 10-07-2007, 08:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts