+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 17

Thread: Run Text Files as Executables

  1. #1
    MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all
    Join Date
    May 2008
    Posts
    476

    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. #2
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    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

  3. #3
    MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all
    Join Date
    May 2008
    Posts
    476

    Re: Run Text Files as Executables

    Lol thanks...

  4. #4
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    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

  5. #5
    Code Warrior dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta's Avatar
    Join Date
    Oct 2007
    Age
    19
    Posts
    2,843
    Blog Entries
    8

    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.

  6. #6
    MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all
    Join Date
    May 2008
    Posts
    476

    Re: Run Text Files as Executables

    DELETED

    Yeah, Slice Ownz Your Posts.

    Get over it

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

  7. #7
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    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

  8. #8
    MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all
    Join Date
    May 2008
    Posts
    476

    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).

  9. #9
    Code Warrior dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta's Avatar
    Join Date
    Oct 2007
    Age
    19
    Posts
    2,843
    Blog Entries
    8

    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 05:25 PM.

  10. #10
    MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all
    Join Date
    May 2008
    Posts
    476

    Re: Run Text Files as Executables

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

+ Reply to Thread
Page 1 of 2
1 2 LastLast

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Project: ionFiles - Joomla Simple File Download
    By Jordan in forum Community Projects
    Replies: 369
    Last Post: 01-30-2010, 01:10 PM
  2. C# Tutorial: Writing Text Files
    By Xav in forum CSharp Tutorials
    Replies: 46
    Last Post: 07-28-2009, 08:18 AM
  3. Text files
    By travy92 in forum Visual Basic Programming
    Replies: 1
    Last Post: 10-07-2007, 10:06 AM
  4. Replies: 3
    Last Post: 09-15-2007, 10:08 PM
  5. Java Help Files
    By xXHalfSliceXx in forum Java Help
    Replies: 3
    Last Post: 11-28-2006, 11:30 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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