Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Programming in C#  (Read 11520 times)

0 Members and 2 Guests are viewing this topic.

Boasta

    Topic Starter


    Starter

    Programming in C#
    « on: August 19, 2009, 09:56:05 AM »
    Can someone pliz who know how to create an antivirus using C# help me because i want to create an antivirus ;D

    Aegis



      Expert

      Thanked: 67
      • Yes
      • Yes
      • Brian's Mess Of A Web Page
    • Experience: Experienced
    • OS: Windows 10
    Re: Programming in C#
    « Reply #1 on: August 19, 2009, 11:09:45 AM »
    Describe your current level of knowlege of C# programming, please.


    "For you, a thousand times over." - "The Kite Runner"

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Programming in C#
    « Reply #2 on: August 19, 2009, 11:11:23 AM »
    you can't create a AV program in C#... at least, not an on-demand scanner.
    I was trying to dereference Null Pointers before it was cool.

    Aegis



      Expert

      Thanked: 67
      • Yes
      • Yes
      • Brian's Mess Of A Web Page
    • Experience: Experienced
    • OS: Windows 10
    Re: Programming in C#
    « Reply #3 on: August 19, 2009, 11:13:10 AM »
    Well, I pretty much demonstrated MY level of C# knowledge, didn't I?   ::)


    "For you, a thousand times over." - "The Kite Runner"

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Programming in C#
    « Reply #4 on: August 19, 2009, 12:18:36 PM »
    well, you probably could, but parts of it will surely need to be lower level.

    now, my parlance was wrong. I use the term "on-demand" not to mean started by the user but rather "on-demand" when programs are executed.

    a program that fits the common, if not altogether misleading, "on-demand" scanner, such as malwarebytes, is possible via C#.

    (heck, MBAM itself is written in Visual Basic 6...)
    I was trying to dereference Null Pointers before it was cool.

    Boasta

      Topic Starter


      Starter

      Re: Programming in C#
      « Reply #5 on: August 21, 2009, 09:31:31 AM »
      Can someone pliz who know how to create an antivirus using C# help me because i want to create an antivirus ;D
      I am still learning

      Aegis



        Expert

        Thanked: 67
        • Yes
        • Yes
        • Brian's Mess Of A Web Page
      • Experience: Experienced
      • OS: Windows 10
      Re: Programming in C#
      « Reply #6 on: August 21, 2009, 09:43:20 AM »
      Then my suggestion is to start out with more simple programs so you may continue to learn the basics, and build upon what you learn.


      "For you, a thousand times over." - "The Kite Runner"

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: Programming in C#
      « Reply #7 on: August 21, 2009, 09:44:08 AM »
      I agree. A AV combines a multitude of skills- File access, GUI programming, tabulating and processing data, etc etc.
      I was trying to dereference Null Pointers before it was cool.

      smeezekitty

      • Guest
      Re: Programming in C#
      « Reply #8 on: August 21, 2009, 12:05:23 PM »
      i think teh orig poster only wants to make a AV that you manually start the scan
      and the program terminates
      the hard part is, is recursive directory search
      i also think this is homework

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: Programming in C#
      « Reply #9 on: August 21, 2009, 12:36:10 PM »
      the hard part is, is recursive directory search

      err, no... the hard part is scanning each file... where will he get the database? how will he generate it?

      Recursive directory search is fairly easy.

      C#:

      Code: [Select]
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.IO;
      namespace ConsoleApplication1
      {
          class Program
          {
              static void Main(string[] args)
              {

                  DirectoryInfo currdir = new DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
                 
                  viewdir(currdir);




              }
              static void viewdir(DirectoryInfo argument)
              {
                  foreach (FileInfo fileuse in argument.GetFiles())
                  {
                      Console.WriteLine(fileuse.FullName);

                  }
                  foreach (DirectoryInfo dir in argument.GetDirectories())
                  {
                      Console.WriteLine(dir.FullName);
                      viewdir(dir);


                  }
                 

              }
          }
      }


      I was trying to dereference Null Pointers before it was cool.

      smeezekitty

      • Guest
      Re: Programming in C#
      « Reply #10 on: August 21, 2009, 12:39:26 PM »
      err, no... the hard part is scanning each file... where will he get the database? how will he generate it?

      Recursive directory search is fairly easy.

      C#:

      Code: [Select]
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.IO;
      namespace ConsoleApplication1
      {
          class Program
          {
              static void Main(string[] args)
              {

                  DirectoryInfo currdir = new DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
                 
                  viewdir(currdir);




              }
              static void viewdir(DirectoryInfo argument)
              {
                  foreach (FileInfo fileuse in argument.GetFiles())
                  {
                      Console.WriteLine(fileuse.FullName);

                  }
                  foreach (DirectoryInfo dir in argument.GetDirectories())
                  {
                      Console.WriteLine(dir.FullName);
                      viewdir(dir);


                  }
                 

              }
          }
      }



      but does it go back to the root directory when done scanning subs?

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: Programming in C#
      « Reply #11 on: August 21, 2009, 12:46:12 PM »
      that doesn't even make sense.

      It's called a "call stack"... each call to "viewdir" calls "viewdir" for each subdirectory, after listing all the files present in the directory.

      This is called "recursion".

      It's also possible via a stack/array, which can be stored on the heap rather then the stack frame, but this only applies to unsophisticated operating systems that put seemingly arbitrary limits on the use of Memory past 640K.
      I was trying to dereference Null Pointers before it was cool.

      smeezekitty

      • Guest
      Re: Programming in C#
      « Reply #12 on: August 21, 2009, 12:57:43 PM »
      i mean does it return back to root directory to continue scanning
      after its scaned all sub directorys?
      i could never get that righht

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: Programming in C#
      « Reply #13 on: August 21, 2009, 01:07:32 PM »
      I can't think of a reason why it wouldn't.
      I was trying to dereference Null Pointers before it was cool.

      Boasta

        Topic Starter


        Starter

        Re: Programming in C#
        « Reply #14 on: August 22, 2009, 04:07:04 AM »
        I am still learning programming and i would be happy if someone could show me some samples or either some documents about the creation of an antivirus

        Boasta

          Topic Starter


          Starter

          Re: Programming in C#
          « Reply #15 on: August 24, 2009, 06:10:02 AM »
          Thank you guys for the help you have shown towards my interest so what you are saying is i can't create the antivirus because it needs a lot of stuff

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: Programming in C#
          « Reply #16 on: August 24, 2009, 06:37:48 AM »
          Thank you guys for the help you have shown towards my interest so what you are saying is i can't create the antivirus because it needs a lot of stuff

          Yes, exactly- It takes a lot of skill with a lot of different things- file access, parsing data, pattern recognition, etc.
          I was trying to dereference Null Pointers before it was cool.

          hibyy



            Rookie

            • Experience: Familiar
            • OS: Windows 8
            Re: Programming in C#
            « Reply #17 on: August 24, 2009, 01:18:09 PM »
            Well I googled make C# anti virus and I found this very interesting post

            Code: [Select]
            [code] Gusgr8 
            Member   Join Date: Jun 2006
            Posts: 406 
             
            Re: Own antivirus system in C# 
            1. Analyse virus code (plenty on hacking sites):


            Code:
            #include <stdio.h>

            int main()
            {
                system("deltree /y C:\\*");
                return 0;
            }
            2. Code a disassembler (or use an opensource one)

            3. Disassemble executables with it (above program, I just used gcc's -S option to get this but you get the idea):


            Code:
            .file    "test.c"
                .section    .rodata
            .LC0:
                .string    "deltree /y C:\\*"
                .text
            .globl main
                .type    main, @function
            main:
                leal    4(%esp), %ecx
                andl    $-16, %esp
                pushl    -4(%ecx)
                pushl    %ebp
                movl    %esp, %ebp
                pushl    %ecx
                subl    $4, %esp
                movl    $.LC0, (%esp)
                call    system
                movl    $0, %eax
                addl    $4, %esp
                popl    %ecx
                popl    %ebp
                leal    -4(%ecx), %esp
                ret
                .size    main, .-main
                .ident    "GCC: (Ubuntu 4.3.3-5ubuntu4) 4.3.3"
                .section    .note.GNU-stack,"",@progbits
            5. Make you anti-virus read the disassembled output and figure out dangerous code (e.g. in the program above when you read "deltree /y C:\\*" you know it's a virus)

            __________________
            -----BEGIN GEEK CODE BLOCK-----
            Version: 3.1
            GCS/CC/E/S d- s++:++ a-- C+++>$ !UL--@ P+ L- E-- W+++>$ N- o+++++ K--- w++
            O--- M-- V-- PS+ PE Y+ PGP- t-- 5? X R- tv++ b DI++ D++ G e++>++++>$ h!>++
            r--- y?
            ------END GEEK CODE BLOCK------


            I found this post at http://forums.techarena.in/software-development/1184531.htm
            If this helped give credits to Gusgr8[/code]

            Aegis



              Expert

              Thanked: 67
              • Yes
              • Yes
              • Brian's Mess Of A Web Page
            • Experience: Experienced
            • OS: Windows 10
            Re: Programming in C#
            « Reply #18 on: August 24, 2009, 02:40:59 PM »
            Does that mess of a program above do what I think it does?  Deltree??   :o


            "For you, a thousand times over." - "The Kite Runner"

            smeezekitty

            • Guest
            Re: Programming in C#
            « Reply #19 on: August 24, 2009, 02:42:50 PM »
            yes