Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Net Spy: Your Network Spy That Monitor Your System In Network And Generate Log For Any Changes

0.00/5 (No votes)
16 Feb 2008 1  
This is a windows based tool to continuous monitor your shared folder in network and generated a log for different folder.

Download SpyNet_New_Release.zip - 62.43 KB
Download NetWorkSpy_Source_Code_New_Release.zip - 717.85 KB
New_Block_Diagrams_Net.JPG

Description

This is a small window based tool which will continuous monitor you shared folder in network . It will give a popup message when ever any user in network accessing your system. You can also get information about user system and a log will generate in this application that which folder user accessed, which filed has been changed, delete, created etc. Features:

1.It will display all of you shared folder in a grid view
2.Popup indication when any user acceding your system
3.List of folder access by user.
4.Name of folder and files that are changed, Created, Deleted or renamed by user.
5.Details information of Remote user system
6.Notify Icon on System Tray
7. Save Logged Details to a text files


Screen Flash

Screen_Flash.JPG

Designed and Process Flow

SpyNet will run on a stand alone system in network. When any user accesses the system it will show a pop up message that “User A” is accessing you System. This tool contain some Data grid to store the information of User, Own System information and it will keep track of all file changing information of user. USer can looged all the details in a text file also

ProcessFlow.JPG

Details Description:

This tool has four main section
1.Shared Folder
2.Current Session
3.Access Folder
4.Folder Watcher
Folder Watcher has the following section
A.Created
B.Deleted
C.Renamed
D.Changed

1.Shared Folder:

In main screen user should able to get list of all shared folder of own system. You should able to see Shred folder name, Path, Description and Status . When any user access a folder Automatically folder watch start and will logged the changes. [ Avoid you System Folder as a Shared Folder. Because There are many changes by default in that so it will keep all track and it may cause some Exception ]

Shared_Folder.JPG

2.Current Session:

Current Section Tab will display who is accessing your System right now. And what is the total access time, Ideal Time, Remote User IP and OS name user should able to get. If any single user access two time ( by giving your IP Address) , It will create two different entry for that.

Current_Session.JPG

While any new user accessing your system , you will get a popup Alert on that.
PopUP_Notifier_New.JPG

This is the indication to you that a new user now accessing you system. You can change the “Refresh Speed” from setting. And you can also disable the pop up notification also from setting menu.
Settings_Menu.JPG

3.Accessed Folder:

This is the list of folder that is accessed by the user. If user access any of you shared folder a logged will generate on that. You can see it from “Access Folder” Tab.

AccessFolder.JPG


4. Folder Watcher:

This is one of the main section of SpyNet Tool . This section it self contain 4 sub section that keep track of each and every individual Files and folder change , delete , rename and Create .

These section are :

a)Created :

This will give you the details of Created file information that is what are the new file is being created by the Remote user with proper file path and date time.

Create_List.JPG

b)Deleted :

This will keep the track of deleted file by the remote user. So what every file from user shared folder deleted by any of remote user will be recorded by SpyNet.

Delete_List.JPG

c) Renamed:

Will the rename file list will keep recorded by this SpyNet. It will keep track of files old name and with its new Name and also date and Time.

Rename_List.JPG


d) Changed :

If any file has been changed by the remote user, it will keep a track of that file , that what file is changed with date and Time

Chnaged.JPG

When SpyNet is Running in You System, you can check it form your System Try. A notify Icon should be there and you can close and restore the application from there.
ContextMenu.JPG

Save Log To Text File

What ever Changed are tace by SpyNet to your shared folder you can save it to Log file as (.txt) format for future use
Log_Generation.JPG

Technical Description

This Tool is developed using C# Windows based Application. I haved WMI ( Windows Management Instrumentation ) and MQL ( Management Query Lanagauge) For Retrive this sustem information. Main File
System.management.dll
Code For Read All Shared Folder in Systems
 private void Read_Shared_Folder()
        {
            int cnt = 0;
            try
            {
               // MQL for Shaer Information
                ManagementObjectSearcher searcher =
                    new ManagementObjectSearcher("root\\CIMV2","SELECT * FROM Win32_Share");

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    RDirPath = queryObj["Path"].ToString();
                    if (!RDirPath.Equals("") || RDirPath.Equals("IPC$") || RDirPath.Equals("ADMIN$") )
                    {
                        File_Watcher(RDirPath);
                    }
                    load_Shared_Item(cnt, queryObj["Name"].ToString(), queryObj
["Path"].ToString(), queryObj["Description"].ToString(), queryObj
["Status"].ToString() );
cnt=cnt+1; } } catch (ManagementException e) { MessageBox.Show("An error occurred while querying for WMI
data: "
+ e.Message); } }
Read The user name for current session

  private  void Read_Current_Session()
        {
            int counter = 0;
            int ActiveTime;
            int itime;
            string sharename;
            try
            {
                ManagementObjectSearcher searcher =
                   new ManagementObjectSearcher("root\\CIMV2",
                   "SELECT * FROM Win32_ServerConnection");
                ManagementObjectSearcher searcher2 =
                   new ManagementObjectSearcher("root\\CIMV2",
                   "SELECT * FROM Win32_ServerSession"); 
                // Read the object 
                foreach (ManagementObject ServerQobj in searcher2.Get())
                {
                    RemoteOS = ServerQobj["ClientType"].ToString();
                    IDealTime = ServerQobj["IdleTime"].ToString();
                    itime = Int32.Parse(IDealTime) / 60;
                    IDealTime = itime.ToString();
                }

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    RemoteIPAddress = queryObj["ComputerName"].ToString();
                    RemoteUserName = queryObj["UserName"].ToString();
                    RemoteActiveTime = queryObj["ActiveTime"].ToString();
                    ActiveTime = (Int32.Parse(RemoteActiveTime)) / 60;
                    RemoteActiveTime = ActiveTime.ToString();
                    sharename = queryObj["ShareName"].ToString();
                    if (!sharename.Equals("IPC$"))
                    {
                        Load_Current_Session(counter, RemoteIPAddress, 
RemoteUserName, RemoteActiveTime,IDealTime,RemoteOS); load_Access_folder(counter, RemoteUserName, sharename); counter += 1; } } } catch (ManagementException e) { MessageBox.Show("An error occurred while querying for WMI
data: "
+ e.Message); } }
Using File Watcher To Watch Shred Files and Folder

  private void File_Watcher(string sFolderPath)
        {
                FileSystemWatcher mywatcher = new FileSystemWatcher(sFolderPath);           
                mywatcher.Filter = "";
                mywatcher.NotifyFilter = NotifyFilters.CreationTime | 
NotifyFilters.DirectoryName | NotifyFilters.FileName |
NotifyFilters.LastAccess ; mywatcher.EnableRaisingEvents = true; mywatcher.IncludeSubdirectories = true; mywatcher.Created += new FileSystemEventHandler
(mywatcher_created); mywatcher.Deleted += new FileSystemEventHandler
(mywatcher_deleted); mywatcher.Changed += new FileSystemEventHandler
(mywatcher_changed); mywatcher.Renamed += new RenamedEventHandler
(mywatcher_renamed); mywatcher_List[iWatcherCount] = mywatcher; iWatcherCount++; }

Code File Created information

 protected void mywatcher_created(object sender,FileSystemEventArgs  e)
        {
           CheckForIllegalCrossThreadCalls = false;
           DateTime current = DateTime.Now;
           lstCreate.Items.Add(e.FullPath.ToString() );
           lstCreate.Items[cCount].SubItems.Add(current.ToShortDateString());
           lstCreate.Items[cCount].SubItems.Add(current.ToShortTimeString());
           cCount += 1;
              }

Code For Taskbar Initilization

 private void TaskBar_Initilization()
         {
             taskbarNotifier1.SetBackgroundBitmap
("
Skin.bmp"
, Color.FromArgb(255,
0, 255)); taskbarNotifier1.SetCloseBitmap
("close.bmp", Color.FromArgb(255, 0, 255), new Point(127, 8)); taskbarNotifier1.TitleRectangle = new Rectangle(40, 9, 70, 25); taskbarNotifier1.ContentRectangle = new Rectangle(8, 41, 133, 68); taskbarNotifier1.TitleClick += new EventHandler(TitleClick); taskbarNotifier1.ContentClick += new EventHandler(ContentClick); taskbarNotifier1.CloseClick += new EventHandler(CloseClick); }

Code For Show Popup


 void Show_popUP()
        {
            string t1 = "500";
            string t2 = "3000";
            string t3 = "500";
            taskbarNotifier1.CloseClickable = true;
            taskbarNotifier1.TitleClickable = false;
            taskbarNotifier1.ContentClickable = true;
            taskbarNotifier1.EnableSelectionRectangle = true;
            taskbarNotifier1.KeepVisibleOnMousOver = true;	
            taskbarNotifier1.ReShowOnMouseOver = true;			
            taskbarNotifier1.Show("NetSpy", RemoteUserName + "\n Is Now 
Accessing Your System "
, Int32.Parse(t1), Int32.Parse(t2), Int32.Parse
(t3)); }

Reference

I have used following code From CodeProject For taskbar notification module TaskBar Notification

Points of Interest

This is a Tool which make your system secure !!! Code is available so you can customized it in your own way

Future Target

1. One Log file to store the Log Records
This featurs is now added in this tool , please check with latest code. User should able to save records in a text file. 2. Clear Log History
3. Some Advance Settings for monitor user.

History

NetSpy Version 1.0 Released 02/01/2008
BugFixed and Logging Featurs Added NetSpy Version 1.0 Released 15/01/2008

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here