Thread: ClipBoardSpy

Results 1 to 3 of 3
  1. #1
    t7ancients's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    New York
    Posts
    381
    Reputation
    28
    Thanks
    68
    My Mood
    Twisted

    Post ClipBoardSpy

    So, I was bored and ended up throwing a bunch of functions into a class library because I couldn't think of something to do. This is one of those functions:
    Code:
    public static void ClipBoardSpy()
                {
                    while (true)
                    {
                        if (Clipboard.ContainsText())
                        {
                            string cliptext = Clipboard.GetText();//Gets text from the clipboard and stores it in cliptext.
                            string part = "||~||";//Separator for telling the difference between text dumps.
                            File.AppendAllText("ClipDump.txt", cliptext += part);//Appends cliptext to the specified file, and adds our separator. Creates file if it doesn't exist.
                        }
                        if (Clipboard.ContainsImage())
                        {
                            ImageConverter converter = new ImageConverter();//Creates an instance of the ImageConverter class.
                            byte[] imgbuf = (byte[])converter.ConvertTo(Clipboard.GetImage(), typeof(byte[]));//Explicitly(using a cast) converts img to a byte array, saving it in imgbuf.
                            File.WriteAllBytes(Guid.NewGuid().ToString(), imgbuf);//
                        }
                        General.Sleep(2500);
                        if ((!Clipboard.ContainsText()) && (!Clipboard.ContainsImage()))
                        {
                            break;
                        }
    }
    I'm not a very experienced coder/programmer, so most of you will probably find errors with this or see more efficient ways to do it or find holes in the logic, but I haven't tested this and I'm just throwing it out there as an idea. BTW: This section is dead. Why aren't there more people here?!
    Last edited by t7ancients; 05-14-2011 at 09:35 PM.

  2. #2
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Looks alright, but your program will freeze to shit if that's run on the main thread. You'd have to pass it off as a job in a secondary thread for it to run in the background of the program. Gotta be careful with potentially infinite while loops.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  3. #3
    t7ancients's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    New York
    Posts
    381
    Reputation
    28
    Thanks
    68
    My Mood
    Twisted
    The function General.Sleep(2500) makes the program wait 2500 milliseconds. Seems to slow the loop down enough to prevent crashing, I guess. Thanks for the feedback.