Click here to Skip to main content
6,629,377 members and growing! (18,889 online)
Email Password   helpLost your password?
Languages » C# » Utilities     Intermediate License: The Code Project Open License (CPOL)

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

By Abhijit Jana

This is a windows based tool to continuous monitor your shared folder in network and generated a log for different folder.
C# (C# 2.0), .NET (.NET 2.0), Dev
Posted:1 Jan 2008
Updated:16 Feb 2008
Views:55,978
Bookmarked:134 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
52 votes for this article.
Popularity: 6.88 Rating: 4.01 out of 5
2 votes, 3.8%
1
3 votes, 5.8%
2
2 votes, 3.8%
3
8 votes, 15.4%
4
37 votes, 71.2%
5

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Abhijit Jana


Member
Abhijit has done Master Degree in Computer Application from Heritage Institute of Technology (HIT-K) ,Kolkata, West Bengal, India . He is an interested, committed, creative Software professional having more than 2.8 years of solid experience in web-based and windows based solutions in Microsoft Technologies using .NET 2.0, .NET 3.0 , .NET 3.5, ASP.NET 2.0, ASP.NET 3.5 C# 2.0, AJAX, Silverlight, Web Services, MS SQL Server 2005, Exchange Server, Active Directory, and Dot Net Nuke (DNN),Win Forms, WinServices, WSS (Windows Sharepoint Server 3.0 ), WPF, WWF. He is also an MCP (Microsoft Certified Professional) and MCTS (Microsoft Certified Technology Specialist) on Web Development. He has good knowledge of Object Oriented Programming, 3-Tier Architecture and Design Patterns as well as good command over IIS (IIS 5.1,IIS 6.0, IIS 7.0) and deployment of Application on Live Production Environment . His hobbies, listing to music and Developing Own small Tools Utilities and Knowledge sharing.


Awards
CodeProject MVP 2009
Prize winner "Best ASP.NET article of Sep 2009
Prize winner "Best ASP.NET article of July 2009
Prize winner "Best ASP.NET article of June 2009"
Prize winner "Best ASP.NET article of January 2009"
Prize winner "Best ASP.NET article of November 2008"

Prize winner "Best ASP.NET article of October 2008"

Abhijit's CodeProject Guru :
Sacha Barber
Occupation: Software Developer (Senior)
Location: India India

Other popular C# articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 80 (Total in Forum: 80) (Refresh)FirstPrevNext
GeneralAbout Folder Monitor Pinmembertopcatzhao197820:14 21 Oct '09  
Generalit crashes on my system... Pinmembermarc ochsenmeier4:45 31 Jul '09  
GeneralRe: it crashes on my system... PinmvpAbhijit Jana10:34 26 Sep '09  
GeneralNice Tool PinmemberBrij3:12 24 Dec '08  
GeneralRe: Nice Tool PinmemberAbhijit Jana5:45 24 Dec '08  
GeneralCool work PinmemberDr.Luiji12:07 18 Dec '08  
GeneralRe: Cool work PinmemberAbhijit Jana19:30 18 Dec '08  
GeneralNew Features PinmemberCosby22:21 4 Nov '08  
GeneralRe: New Features PinmemberAbhijit Jana21:44 24 Nov '08  
GeneralNice ! ! ! Pinmemberyair_chen11:36 10 Aug '08  
GeneralRe: Nice ! ! ! PinmemberAbhijit Jana18:16 10 Aug '08  
QuestionFolder Watcher Pinmemberlambertlbz1:04 31 Jul '08  
AnswerRe: Folder Watcher PinmemberAbhijit Jana6:26 1 Aug '08  
QuestionRe: Folder Watcher Pinmemberlambertlbz18:24 12 Aug '08  
AnswerRe: Folder Watcher PinmemberAbhijit Jana1:28 16 Aug '08  
GeneralPost Mortem Debugging PinmemberRobinBlood0:59 5 Jul '08  
GeneralRe: Post Mortem Debugging PinmemberAbhijit Jana1:51 5 Jul '08  
GeneralDisplay Username PinmemberHolger_017:38 30 Jun '08  
GeneralRe: Display Username PinmemberAbhijit Jana7:41 30 Jun '08  
GeneralRe: Display Username [modified] PinmemberHolger_0110:20 30 Jun '08  
Questionwhy can't monitor the file change event? Pinmemberhuangqiqing@live.cn7:03 30 Jun '08  
AnswerRe: why can't monitor the file change event? PinmemberAbhijit Jana7:10 30 Jun '08  
GeneralRe: why can't monitor the file change event? Pinmemberhuangqiqing@live.cn7:23 30 Jun '08  
GeneralRe: why can't monitor the file change event? PinmemberAbhijit Jana7:45 30 Jun '08  
GeneralRe: why can't monitor the file change event? Pinmemberhuangqiqing@live.cn16:29 30 Jun '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 16 Feb 2008
Editor:
Copyright 2008 by Abhijit Jana
Everything else Copyright © CodeProject, 1999-2009
Web17 | Advertise on the Code Project