any trace of virus in this source code?

BlitzMax Forums/BlitzMax Beginners Area/any trace of virus in this source code?

mooney12(Posted 2016) [#1]
friend sent me this program along with this source code and im wondering if theres any sort of keylogger coded in. can someone please check?

it is supposed to check players online in a game using the information from the game website.

'GUILD INFORMANT
'Use it for good, never evil.
'IT WILL RUN AS A COMMAND LINE PROGRAM

SuperStrict

Import BRL.SocketStream

Const MEMBERS_FILE:String="Members.txt" 'File with the member names
Const CFG_FILE:String="configuration.cfg" 'File with configuration

Type PROGRAM_TYPE
Field ALARMSOUND_FILE:String="" 'No alarm right now
Field AlarmSound:TSound
Field PlayAlarm:Int=0 'Play alarm?
Field CStream:TStream 'Stream for file with configurations
Field MStream:TStream 'Stream for file with members
Field AutoUpdate:Int=0 '0=Off 1=On
Field AutoUpdateTime:Int=10 '10 seconds is standard update time
Field AutoUpdateTimer:Int=MilliSecs() 'Timer for updater
Field CommandLine:String="" 'Command line
Field CMDTimer:Int=0 'Command line cursor timer
Field CMDCursorStatus:Int=0 'Command line cursor status (1=Show 0=Hide -1=Invalid Command)

Field KillProgram:Int=0 'Kill program?

'Processes Commands
Method ProcessCommand()
If CommandLine="exit" Then
KillProgram=1
ElseIf Left(CommandLine,6)="alarm " And Len(CommandLine)>6 Then
CommandLine=Right(CommandLine,Len(CommandLine)-6)
If CommandLine="off" Then
CStream=WriteStream(CFG_FILE)
If Not CStream Then RuntimeError("Error while writing "+CFG_FILE+" file!")

WriteLine(CStream,"Alarm off")

CloseStream(CStream)
ALARMSOUND_FILE=""
AlarmSound=Null
Else
CStream=WriteStream(CFG_FILE)
If Not CStream Then RuntimeError("Error while writing "+CFG_FILE+" file!")

ALARMSOUND_FILE=CommandLine+".wav"
AlarmSound=LoadSound(ALARMSOUND_FILE)
If Not AlarmSound Then
ALARMSOUND_FILE=""
WriteLine(CStream,"Alarm off")
Else
WriteLine(CStream,"Alarm on")
WriteLine(CStream,CommandLine)
EndIf

CloseStream(CStream)
EndIf
ElseIf CommandLine="update" Then
UpdateStatus()
ElseIf CommandLine="autoupdate" Then
AutoUpdate=1
AutoUpdateTimer=MilliSecs()
ElseIf CommandLine="manual update" Then
AutoUpdate=0
ElseIf Left(CommandLine,15)="set update time" Then
If Len(CommandLine)=18 Then '2 digits time
CommandLine=Right(CommandLine,2) 'Last 2 digits
AutoUpdateTime=CommandLine.ToInt()
ElseIf Len(CommandLine)=17 Then '1 digit time
CommandLine=Right(CommandLine,1) 'Last 1 digit
AutoUpdateTime=CommandLine.ToInt()
Else
CMDCursorStatus=-1
CMDTimer=MilliSecs()
EndIf

If AutoUpdateTime>99 Or AutoUpdateTime<10 Then
AutoUpdateTime=10
EndIf
Else
CMDCursorStatus=-1
CMDTimer=MilliSecs()
EndIf

CommandLine=""
End Method

'Checks players status
Method UpdateStatus()
CheckStatus("http://www.medivia.org/community/online/")
End Method

'Draws the command written on command line
Method DrawCommandLine()
SetColor(255,255,255)
If (MilliSecs()-CMDTimer)>1000 Then
If CMDCursorStatus=-1 Then
CMDCursorStatus=0
Else
CMDCursorStatus=Not CMDCursorStatus
EndIf

CMDTimer=MilliSecs()
EndIf

If CMDCursorStatus=0 Then
DrawText(">"+CommandLine,15,25)
ElseIf CMDCursorStatus=1 Then
DrawText(">"+CommandLine+"_",15,25)
Else
DrawText(">_Invalid Command",15,25)
EndIf
End Method

'Draws Members List
Method DrawStatus()
'Alarm Settings
SetColor(0,0,255)
If ALARMSOUND_FILE Then
DrawText("Alarm on",400,40)
DrawText("Alarm Sound File:",400,55)
DrawText(ALARMSOUND_FILE,420,70)
Else
DrawText("Alarm off",400,40)
EndIf

If AutoUpdate=1 Then
DrawText("AutoUpdate: On",400,100)
DrawText("AutoUpdate Time: "+AutoUpdateTime,400,115)
Else
DrawText("AutoUpdate: Off",400,100)
EndIf

Local YOffset:Int=0

For Local TempMember:MEMBER_TYPE=EachIn MEMBERS_LIST
If TempMember.Status=0 Then
SetColor(255,0,0) 'Red=offline
DrawText(TempMember.Name + " - Offline",15,40+YOffset)
ElseIf TempMember.Status=1 Then
SetColor(0,255,0) 'Green=online
DrawText(TempMember.Name + " - Online",15,40+YOffset)
ElseIf TempMember.Status=-1 Then
SetColor(255,0,255) 'Green=online
DrawText(TempMember.Name + " - No Connection to medivia.org",15,40+YOffset)
ElseIf TempMember.Status=3 Then
SetColor(255,255,0) 'Green=online
DrawText(TempMember.Name + " - Unknown",15,40+YOffset)
EndIf

YOffset:+15
Next
End Method

'Members file consists only of the members names on each line. An empty line adds no member
Method LoadMembers()
MStream=ReadStream(MEMBERS_FILE)
If Not MStream Then RuntimeError("File "+MEMBERS_FILE+" not found")

Local TempLine:String
Local TempMember:MEMBER_TYPE
Local ID:Int=0

While Not Eof(MStream)
TempLine=ReadLine(MStream)

If TempLine Then
TempMember=New MEMBER_TYPE
TempMember.Name=TempLine

MEMBERS_LIST.AddLast(TempMember)
EndIf
Wend

CloseStream(MStream)
End Method

'The configuration file is simple. It will define an alarm for the program (which will be set off
'everytime some status change) with a line "Alarm on" followed by the alarmsound file.
'Anything else will be considered as an "Alarm off" file.
Method LoadConfig()
CStream=ReadStream(CFG_FILE)
If Not CStream Then RuntimeError("File "+CFG_FILE+" not found!")

If ReadLine(CStream)="Alarm on" Then
ALARMSOUND_FILE=ReadLine(CStream)+".wav"
AlarmSound=LoadSound(ALARMSOUND_FILE)
If Not AlarmSound Then ALARMSOUND_FILE=""
Else
ALARMSOUND_FILE=""
EndIf

CloseStream(CStream)
End Method
End Type

Global MEMBERS_LIST:TList=CreateList() 'List with all the members

'MEMBERS TYPE
Type MEMBER_TYPE
Field Name:String
Field Status:Int=0 '1=ONLINE ; 0=OFFLINE
Field OldStatus:Int=0 'Old status for alarm triggering
End Type

Graphics 600,460

'Program Object
Global Program:PROGRAM_TYPE=New PROGRAM_TYPE

'Loading configurations and making members list
Program.LoadConfig()
Program.LoadMembers()

'MAIN LOOP
Repeat
'Draws Title
SetColor(255,255,255)
DrawText("Guild Informant v0.1",10,10)

Program.DrawStatus()
Program.DrawCommandLine()

Select GetChar()
Case Asc("a")'Key_A
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"a"
EndIf
Case Asc("b")'Key_B
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"b"
EndIf
Case Asc("c")'Key_C
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"c"
EndIf
Case Asc("d")'Key_D
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"d"
EndIf
Case Asc("e")'Key_E
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"e"
EndIf
Case Asc("f")'Key_F
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"f"
EndIf
Case Asc("g")'Key_G
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"g"
EndIf
Case Asc("h")'Key_H
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"h"
EndIf
Case Asc("i")'Key_I
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"i"
EndIf
Case Asc("j")'Key_J
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"j"
EndIf
Case Asc("k")'Key_K
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"k"
EndIf
Case Asc("l")'Key_L
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"l"
EndIf
Case Asc("m")'Key_M
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"m"
EndIf
Case Asc("n")'Key_N
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"n"
EndIf
Case Asc("o")'Key_O
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"o"
EndIf
Case Asc("p")'Key_P
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"p"
EndIf
Case Asc("q")'Key_Q
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"q"
EndIf
Case Asc("r")'Key_R
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"r"
EndIf
Case Asc("s")'Key_S
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"s"
EndIf
Case Asc("t")'Key_T
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"t"
EndIf
Case Asc("u")'Key_U
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"u"
EndIf
Case Asc("w")'Key_W
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"w"
EndIf
Case Asc("y")'Key_Y
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"y"
EndIf
Case Asc("x")'Key_X
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"x"
EndIf
Case Asc("z")'Key_Z
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"z"
EndIf
Case Key_0
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"0"
EndIf
Case Key_1
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"1"
EndIf
Case Key_2
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"2"
EndIf
Case Key_3
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"3"
EndIf
Case Key_4
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"4"
EndIf
Case Key_5
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"5"
EndIf
Case Key_6
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"6"
EndIf
Case Key_7
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"7"
EndIf
Case Key_8
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"8"
EndIf
Case Key_9
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+"9"
EndIf
Case Key_Space
If Len(Program.CommandLine)<20 Then
Program.CommandLine:+" "
EndIf
Case Key_Backspace
If Len(Program.CommandLine)>0 Then
Program.CommandLine=Left(Program.CommandLine,Len(Program.CommandLine)-1)
EndIf
Case Key_Enter
Program.ProcessCommand()
End Select

If Program.AutoUpdate=1 Then
If (MilliSecs()-Program.AutoUpdateTimer)>(1000*Program.AutoUpdateTime) Then
CheckStatus("http://www.medivia.org/community/online/")
Program.AutoUpdateTimer=MilliSecs()
EndIf
EndIf

Program.PlayAlarm=0
If Program.ALARMSOUND_FILE Then
For Local M:MEMBER_TYPE=EachIn MEMBERS_LIST
If M.OldStatus=0 And M.Status=1 Then
Program.PlayAlarm=1
M.OldStatus=1
EndIf
Next

If Program.PlayAlarm Then PlaySound(Program.AlarmSound)
EndIf

If Program.KillProgram Then Exit

FlushKeys
Flip;Cls
Forever

Function CheckStatus:Int(Url:String,Port:Int=80)
'Separates information from the URL
If Url.StartsWith("http://") Then Url=Url[7..]
If Url.StartsWith("https://") Then Url=Url[8..]

Local FileStart:Int=Url.Find("/")
Local FileName:String="/"

If FileStart<>-1 Then
FileName=Url[FileStart..]
Url=Url[..FileStart]
EndIf

Local Stream:TStream=TSocketStream.CreateClient(Url,Port)
If Not Stream Then Return -1

Stream.WriteLine "GET "+FileName+" HTTP/1.1"
Stream.WriteLine "Host: "+Url
Stream.WriteLine ""

'Ignore Headers
Local Header:String
Header=Stream.ReadLine()
Header=Stream.ReadLine()
While Header<>""
Header=Stream.ReadLine()
Wend

Local TempLine:String

'Resets Status
For Local M:MEMBER_TYPE=EachIn MEMBERS_LIST
M.OldStatus=M.Status
M.Status=0
Next

Cls
'Draws Title
SetColor(255,255,255)
DrawText("Guild Informant v0.1",10,10)

'Draws Alarm Settings
SetColor(0,0,255)
If Program.ALARMSOUND_FILE Then
DrawText("Alarm on",400,40)
DrawText("Alarm Sound File:",400,55)
DrawText(Program.ALARMSOUND_FILE,420,70)
Else
DrawText("Alarm off",400,40)
EndIf

'Draws Auto update settings
If Program.AutoUpdate=1 Then
DrawText("AutoUpdate: On",400,100)
DrawText("AutoUpdate Time: "+Program.AutoUpdateTime,400,115)
Else
DrawText("AutoUpdate: Off",400,100)
EndIf

'Draws Loading
SetColor(0,255,0)
DrawText(">_UPDATING...",15,25)

Flip;Cls

While Not Stream.Eof()
TempLine=Stream.ReadLine()
For Local M:MEMBER_TYPE=EachIn MEMBERS_LIST
If TempLine.Contains("http://medivia.org/community/character/"+M.Name+"/") Then
M.Status=1
EndIf
Next
Wend

CloseStream(Stream)
End Function


Brucey(Posted 2016) [#2]
Hallo. It appears to do what it says on the tin.

Why would you think there's a keylogger in there?


mooney12(Posted 2016) [#3]
im just paranoid and wanted to check it before i ran it on my computer


Brucey(Posted 2016) [#4]
Well, if you are that paranoid, who's to say the exe you have was built from the source you have ;-)


mooney12(Posted 2016) [#5]
i compiled it and checked it against the original


mooney12(Posted 2016) [#6]
file sizes were exactly the same