Sign in to follow this  
Followers 0
electrico

Warn-Me v1.0

1 post in this topic

Hi dear admins of corporative networks! This time I decided to write a little program that warn users for uncorrect use of computer and network that usually leads to virus epidemies on the network, or OS crash.

Please download, use, and enjoy if you like it.

Source code for 2 part(compile it first):

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiConstants.au3>
#include <SendMessage.au3>
#include <EditConstants.au3>
Global Const $SC_DRAGMOVE = 0x0000 ;0xF012
Opt("GuiOnEventMode", 1)
HotKeySet("{ESC}", "_nothing_special")
HotKeySet("!{F4}", "_nothing_special")
FileInstall("red-alert.bmp", @TempDir & "\red-alert.bmp")
$mygui = GuiCreate ("Warning", 350, 400, -1, -1, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST)
    GuiSetState (@SW_SHOW)
GuiSetBkColor(0xffffff)
GuiCtrlCreatePic(@TempDir & "\red-alert.bmp", 15, 30, 128, 128)
    GuiSetOnEvent($GUI_EVENT_CLOSE, "Close")
    GuiSetOnEvent($GUI_EVENT_PRIMARYDOWN, "_messagetogui")
$exitbutton = GuiCtrlCreateButton("X", 325, 0, 25, 25)
GuiCtrlSetState(-1, $GUI_DISABLE)
GuiCtrlSetOnEvent(-1, "close")
$warn_text = GuiCtrlCreateEdit("This is WARN MESSAGE for breaking the common rules of computer use!" & @CRLF & @CRLF & "Text:" & @CRLF & IniRead("C:\warning.ini", "warnings", @IPAddress1, ""), 20, 160, 310, 150, BitOr($ES_MULTILINE, $ES_READONLY))
$iepazinos = GUICtrlCreateCheckbox("Iepazinos", 100, 350, 120, 20)
GuiCtrlSetOnEvent($iepazinos, "enable_quit")
Func enable_quit()
    Local $iepazinos_state = GuiCtrlGetState($iepazinos)
    If $iepazinos_state = True Then 
    GuiCtrlSetState($exitbutton, $GUI_ENABLE)
    GuiCtrlSetOnEvent($iepazinos, "disable_quit")
    EndIf
EndFunc
Func disable_quit()
    Local $iepazinos_state2 = GuiCtrlGetState($iepazinos)
    If $iepazinos_state2 > 0 Then GuiCtrlSetState($exitbutton, $GUI_DISABLE)
    Return GuiCtrlSetOnEvent($iepazinos, "enable_quit")
EndFunc
Func _messagetogui()
    _SendMessage($mygui, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc 
Func _nothing_special()
    Sleep(10)
EndFunc
Func close()
    Exit
EndFunc
While 1
    Sleep(10)
WEnd

Source code for main gui (here I used nircmd.exe tool, so be so kind to download it and put to the same folder.):

#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Ghostbusters.ico.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiConstants.au3>
#include <SendMessage.au3>
#include <EditConstants.au3>
#include <Advanced_ini.au3>
#include <File.au3>
Global Const $SC_DRAGMOVE = 0xF012
Global $mygui
Opt("GuiOnEventMode", 1)
Opt("MustDeclareVars", 1)
FileInstall ("nircmd.exe", @WindowsDir & "\nircmd.exe", 1)
;Controls
Global $radio1, $radio2
Global $input1, $input2, $input3
Global $button1, $button2, $button3, $button4, $button5, $button6
Global $errlabel1, $errlabel2, $errlabel3, $checkstate, $warninipsfile, $warningusersfile, $blankornot, $pazinojums
Dim $aRecords
;Source
Global $pic1, $pic2
FileInstall("logo.bmp", @TempDir & "\logo.bmp", 1)
FileInstall("devil.bmp", @TempDir & "\devil.bmp", 1)
FileInstall("angel.bmp", @TempDir & "\angel.bmp", 1)
FileInstall("devil.mp3", @TempDir & "\devil.mp3", 1)
FileInstall("angel.mp3", @TempDir & "\angel.mp3", 1)
FileInstall("guitosend.exe", @ProgramFilesDir & "\Warning Table\guitosend.exe", 1)
;Creating program files, registry entries and base location
$warninipsfile = FileExists(@ProgramFilesDir & "\Warning Table\black_ips.ini")
$warningusersfile = FileExists(@ProgramFilesDir & "\Warning Table\black_users.ini")
If $warninipsfile = True Then
    Sleep(10)
Else
_FileCreate(@ProgramFilesDir & "\Warning Table\black_ips.ini")
EndIf
If $warningusersfile = True Then
    Sleep(10)
Else
_FileCreate(@ProgramFilesDir & "\Warning Table\black_users.ini")
EndIf
$mygui = GuiCreate ("Warning table ", 350, 400, 100, 200, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST)
    GuiSetState (@SW_SHOW)
GuiSetBkColor(0xffffff)
    GuiSetOnEvent($GUI_EVENT_CLOSE, "Close")
    GuiSetOnEvent($GUI_EVENT_PRIMARYDOWN, "_messagetogui")
GuiCtrlCreatePic (@TempDir & "\logo.bmp", 270, 10, 50, 43)
GuiCtrlCreateLabel("For text use latin letters only.", 5, 5, 250, 15)
GuiCtrlCreateButton("X", 335, 0, 15, 15)
GuiCtrlSetOnEvent(-1, "close")
AdlibRegister("_authormark", 30000)
GuiCtrlCreateGroup("Method", 40, 70, 270, 80)
$radio1 = GuiCtrlCreateRadio("Warn IP address", 50, 90, 100, 20)
GuiCtrlSetOnEvent(-1, "_enableipfield")
$radio2 = GuiCtrlCreateRadio("Blacklist username", 50, 120, 110, 20)
GuiCtrlSetOnEvent(-1, "_enableuserfield")
$input1 = GuiCtrlCreateInput("", 170, 90, 120, 20)
GuiCtrlSetState(-1, $GUI_DISABLE)
$input2 = GuiCtrlCreateInput("", 170, 120, 120, 20)
GuiCtrlSetState(-1, $GUI_DISABLE)
GuiCtrlCreateLabel("Reason:", 40, 160, 60, 20)
$input3 = GuiCtrlCreateInput("", 40, 175, 270, 60, $ES_MULTILINE)
$button1 = GuiCtrlCreateButton("Warn", 40, 250, 60, 20)
GuiCtrlSetState(-1, $GUI_DISABLE)
GuiCtrlSetOnEvent(-1, "_warnip")
$button2 = GuiCtrlCreateButton("Un-Warn", 40, 275, 60, 20)
GuiCtrlSetState(-1, $GUI_DISABLE)
GuiCtrlSetOnEvent(-1, "_pinghost_unwarnip")
$button3 = GuiCtrlCreateButton("Status", 40, 300, 60, 20)
GUICtrlSetOnEvent(-1, "_getstateofip")
GuiCtrlSetState(-1, $GUI_DISABLE)
$button4 = GuiCtrlCreateButton("Blacklist", 246, 250, 60, 20)
GuiCtrlSetState(-1, $GUI_DISABLE)
GuiCtrlSetOnEvent(-1, "_devilface2")
$button5 = GuiCtrlCreateButton("Un-black", 246, 275, 60, 20)
GuiCtrlSetState(-1, $GUI_DISABLE)
GuiCtrlSetOnEvent(-1, "_angel2")
$button6 = GuiCtrlCreateButton("Status", 246, 300, 60, 20)
GuiCtrlSetOnEvent($button6, "_getuserstate")
GuiCtrlSetState(-1, $GUI_DISABLE)
Func _messagetogui()
    _SendMessage($mygui, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc  
Func _devilface()
    $pic1 = GuiCtrlCreatePic(@TempDir & "\devil.bmp", 120, 240, 85, 87)
    SoundPlay(@TempDir & "\devil.mp3", 1)
    Sleep(1000)
    GuiCtrlDelete($pic1)
EndFunc
Func _angel()
    GuiCtrlDelete($pic1)
    $pic2 = GuiCtrlCreatePic(@TempDir & "\angel.bmp", 120, 240, 85, 87)
    SoundPlay(@TempDir & "\angel.mp3")
    Sleep(4000)
    GuiCtrlDelete($pic2)
EndFunc
Func _devilface2()
    $pic1 = GuiCtrlCreatePic(@TempDir & "\devil.bmp", 120, 240, 85, 87)
    SoundPlay(@TempDir & "\devil.mp3", 1)
    Sleep(1000)
    GuiCtrlDelete($pic1)
    _balcklistuser()
EndFunc
Func _angel2()
    GuiCtrlDelete($pic1)
    $pic2 = GuiCtrlCreatePic(@TempDir & "\angel.bmp", 120, 240, 85, 87)
    SoundPlay(@TempDir & "\angel.mp3")
    Sleep(4000)
    GuiCtrlDelete($pic2)
    _mercyuser()
EndFunc
Func _enableipfield()
GuiCtrlSetState($input2, $GUI_DISABLE)
GuiCtrlSetState($input1, $GUI_ENABLE)
GuiCtrlSetState($input3, $GUI_ENABLE)
GuiCtrlSetState($button1, $GUI_ENABLE)
GuiCtrlSetState($button2, $GUI_ENABLE)
GuiCtrlSetState($button3, $GUI_ENABLE)
GuiCtrlSetState($button4, $GUI_DISABLE)
GuiCtrlSetState($button5, $GUI_DISABLE)
GuiCtrlSetState($button6, $GUI_DISABLE)
EndFunc
Func _enableuserfield()
GuiCtrlSetState($input1, $GUI_DISABLE)
GuiCtrlSetState($input2, $GUI_ENABLE)
GuiCtrlSetState($input3, $GUI_DISABLE)
GuiCtrlSetState($button4, $GUI_ENABLE)
GuiCtrlSetState($button5, $GUI_ENABLE)
GuiCtrlSetState($button6, $GUI_ENABLE)
GuiCtrlSetState($button1, $GUI_DISABLE)
GuiCtrlSetState($button2, $GUI_DISABLE)
GuiCtrlSetState($button3, $GUI_DISABLE)
EndFunc
Func _balcklistuser()
    _IniWriteEx(@ProgramFilesDir & "\Warning table\black_users.ini", "Blacklisted Users", GUICtrlRead($input2), "sucker")
EndFunc
Func _mercyuser()
    _IniWriteEx(@ProgramFilesDir & "\Warning table\black_users.ini", "Blacklisted Users", GUICtrlRead($input2), "good")
EndFunc
GuiCtrlSetTip($input1, "Example: 10.33.0.60")
GuiCtrlSetTip($input2, "Example: Name_Lastname")
GuiCtrlSetTip($input3, "Reason of warn or blacklist. Type it here.")
Func _pinghost_unwarnip()
If GuiCtrlRead($input1) > "" Then
    Ping (GUICtrlRead($input1))
            _angel()
            _unwarnip()
            Else
        $errlabel3 = GuiCtrlCreateLabel("Please provide IP address", 115, 350, 300, 20)
        GuiCtrlSetColor(-1, 0xCC3300)
        Sleep(5000)
        GuiCtrlDelete($errlabel3)
EndIf
EndFunc
Func _warnip()
        If GuiCtrlRead($input1) > "" Then
    Ping (GUICtrlRead($input1))
                If @error = 0 Then
                    ;here func to send exe with warning text to remote cpu.
                    _warn()
                    _IniWriteEx(@ProgramFilesDir & "\Warning table\black_ips.ini", "Blocked IP", GUICtrlRead($input1), "warned")
                    ;and
                    ;2. here must receive from other host that he agree with a warning
                Else
                    $errlabel1 = GuiCtrlCreateLabel("Host is dead or unreachable", 100, 350, 300, 20)
                    GuiCtrlSetColor(-1, 0xCC3300)
                    Sleep(5000)
                    GuiCtrlDelete($errlabel1)
                EndIF
            Else
        $errlabel2 = GuiCtrlCreateLabel("Please provide IP address", 115, 350, 300, 20)
        GuiCtrlSetColor(-1, 0xCC3300)
        Sleep(5000)
        GuiCtrlDelete($errlabel2)
    EndIf       
EndFunc
Func _warn()
        _IniWriteEx(@ProgramFilesDir & "\Warning table\black_ips.ini", "Blocked IP", GUICtrlRead($input1), "warned")
        _devilface()
        $pazinojums = GuiCtrlCreateLabel("IP " & GuiCtrlRead($input1) & " has been warned", 115, 350, 300, 20)
        GuiCtrlSetColor(-1, 0xCC3300)
        Sleep(5000)
        GuiCtrlDelete($pazinojums)
        _FileCreate(@ProgramFilesDir & "\Warning Table\warning.ini")
    IniWrite(@ProgramFilesDir & "\Warning Table\warning.ini", "warnings", GuiCtrlRead($input1), GuiCtrlRead($input3))
    FileCopy(@ProgramFilesDir & "\Warning Table\warning.ini", "\\" & GuiCtrlRead($input1) & "\C$\warning.ini", 1)
    FileCopy(@ProgramFilesDir & "\Warning Table\guitosend.exe", "\\" & GuiCtrlRead($input1) & "\C$\guitosend.exe", 1)
    ;remotely somehow interactively launch file - done
    RunWait('nircmd.exe remote copy ' & '\\' & GuiCtrlRead($input1) & ' exec show ' & 'C:\guitosend.exe', @WindowsDir, @SW_HIDE)
EndFunc
Func _unwarnip()
    _IniWriteEx(@ProgramFilesDir & "\Warning table\black_ips.ini", "Blocked IP", GUICtrlRead($input1), "clean")
EndFunc
Func _getstateofip()
    $checkstate = _IniReadEx(@ProgramFilesDir & "\Warning table\black_ips.ini", "Blocked IP", GUICtrlRead($input1))
     If $checkstate = "clean" Then
         GuiCtrlCreateLabel("IP has got a mercy", 130, 350, 300, 20)
         GuiCtrlSetColor(-1, 0x088A08)
         Sleep(5000)
         GuiCtrlDelete(-1)
     ElseIf $checkstate = "warned" Then
         GuiCtrlCreateLabel("IP is warned", 140, 350, 300, 20)
         GuiCtrlSetColor(-1, 0xCC3300)
         Sleep(5000)
         GuiCtrlDelete(-1)
     Else
         MsgBox(64, "", GuiCtrlRead($input1) & " has never received warnings")
    EndIf
EndFunc
Func _getuserstate()
    $checkstate = _IniReadEx(@ProgramFilesDir & "\Warning table\black_users.ini", "Blacklisted Users", GUICtrlRead($input2))
     If $checkstate = "good" Then
         GuiCtrlCreateLabel("User has got a mercy", 130, 350, 300, 20)
         GuiCtrlSetColor(-1, 0x3399ff)
         Sleep(5000)
         GuiCtrlDelete(-1)
     ElseIf $checkstate = "sucker" Then
         GuiCtrlCreateLabel("User is blacklisted", 140, 350, 300, 20)
         GuiCtrlSetColor(-1, 0x000000)
         Sleep(5000)
         GuiCtrlDelete(-1)
     Else
         MsgBox(64, "", GuiCtrlRead($input2) & " has never been blacklisted")
    EndIf
EndFunc
Func close()
    Exit
EndFunc
Func _nothing()
    Sleep(10)
EndFunc
Func _authormark()
    GuiCtrlCreateLabel("Programmed by electrico for free use.", 20, 380, 330, 20)
    Sleep(3000)
    GuiCtrlDelete(-1)
Endfunc
While 1
    Sleep(10)
WEnd

Waiting for your reply, feedback and remarks.

Have a nice time.

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0