Trojan Virus emanating from my Code

Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/* pattern.c
 * --------------
 * This file makes a nice pattern when you enter a number.
 * Code by Usandfriends.
 */

#include <stdio.h>
#include <stdlib.h>
#include "genlib.h"
#include "simpio.h"
#include "strlib.h"
#include "concol.h"

#include <iostream>
#include <string>
#include <windows.h>

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;

int reverse (int ending);
static void InitScreen(void);
void gotoXY(int x,int y);

void gotoXY(int x,int y) 
{ 
CursorPosition.X = x; 
CursorPosition.Y = y; 
SetConsoleCursorPosition(console,CursorPosition); 
}

int reverse (int ending)
{
    int reverse;
    reverse=0;
    
    while (ending!=0)
    {
         reverse = reverse * 10;
         reverse = reverse + ending%10;
         ending = ending/10;
    }
    return(reverse);
}

static void InitScreen(void)
{
       string spac_init;
       int iij;
       setcolor(yellow,red);
       spac_init="";
       for(iij=0;iij<24000;iij++)
       {
            spac_init=Concat(" ",spac_init);
       }
       printf ("%s",spac_init);
       gotoXY(0,0);
}

main()
{
      InitScreen();
      int n,i,j,width,num,mun,nmn,loop,loop1,ending,beginning_int,muner;
      string answer,count_str,beginning;
      char mun_str[100];
      char loop_str[100];
      
      start:
      printf ("Number?\n\n  > ");
      n=GetInteger();
      printf ("\n\n\n\n");
      
      if ((n<1)||(n>9))
      {
           printf ("Number cannot be greater than 10 or less than 1. Please retry.\n");
           goto start;
      }
      
      width=(2*n)-1;
      answer="";
      beginning="";
      answer="";
      loop=0;
      loop1=0;
      num=0;
      mun=1;
      j=n;
      
      for(i=1;i<=width;i++)
      {
           if (i<=n)
           {
                itoa(mun,mun_str,10);
                loop++;
                for (nmn=1;nmn<=width-num;nmn++)
                {
                     answer=Concat(answer,mun_str);
                }
                if (i==1)
                     {goto end;}
                for (muner=1;muner<loop;muner++)
                {
                     loop1++;
                     itoa(loop1,loop_str,10);
                     beginning=Concat(beginning,loop_str);
                }
                end:
                beginning_int=atoi(beginning);
                ending=reverse(beginning_int);
                num=num+2;
                mun++;
                j=j-1;
                if (i==1)
                     {printf ("%s\n",answer);}
                else{
                     printf ("%d%s%d\n",beginning_int,answer,ending);}
                goto SaveCopy;
                endSaveCopy:
                loop1=0;
                answer="";
                beginning="";
           }
           else
                {break;}
      }
      goto PrintLast;

      
       SaveCopy:
       int beginning1,beginning2,beginning3,beginning4,beginning5,beginning6,beginning7,beginning8;
       string answer1,answer2,answer3,answer4,answer5,answer6,answer7,answer8;
       int ending1,ending2,ending3,ending4,ending5,ending6,ending7,ending8;
       
       if(j==1){ 
            beginning1=beginning_int;
            answer1=answer;
            ending1=ending;
            }
       else if(j==2){
            beginning2=beginning_int;
            answer2=answer;
            ending2=ending;
            }
       else if(j==3){
            beginning3=beginning_int;
            answer3=answer;
            ending3=ending;
            }
       else if(j==4){
            beginning4=beginning_int;
            answer4=answer;
            ending4=ending;
            }
       else if(j==5){
            beginning5=beginning_int;
            answer5=answer;
            ending5=ending;
            }
       else if(j==6){
            beginning6=beginning_int;
            answer6=answer;
            ending6=ending;
            }
       else if(j==7){
            beginning7=beginning_int;
            answer7=answer;
            ending7=ending;
            }
       else if(j==8){
            beginning8=beginning_int;
            answer8=answer;
            ending8=ending;
            }
       goto endSaveCopy;
       
       
       PrintLast:
       int njm;
       
       for(njm=1;njm<n;njm++)
       {
            if(njm==1)
            {if(n==2)
                 {printf("%s\n",answer1);}
                 else {printf ("%d%s%d\n",beginning1,answer1,ending1);}}
            else if(njm==2)
            {if(n==3)
                 {printf("%s\n",answer2);}
                 else{printf ("%d%s%d\n",beginning2,answer2,ending2);}}
            else if(njm==3)
            {if(n==4)
                 {printf("%s\n",answer3);}
                 else{printf ("%d%s%d\n",beginning3,answer3,ending3);}}
            else if(njm==4)
            {if(n==5)
                 {printf("%s\n",answer4);}
                 else{printf ("%d%s%d\n",beginning4,answer4,ending4);}}
            else if(njm==5)
            {if(n==6)
                 {printf("%s\n",answer5);}
                 else{printf ("%d%s%d\n",beginning5,answer5,ending5);}}
            else if(njm==6)
            {if(n==7)
                 {printf("%s\n",answer6);}
                 else{printf ("%d%s%d\n",beginning6,answer6,ending6);}}
            else if(njm==7)
            {if(n==8)
                 {printf("%s\n",answer7);}
                 else{printf ("%d%s%d\n",beginning7,answer7,ending7);}}
            else if(njm==8)
            {if(n==9)
                 {printf("%s\n",answer8);}
                 else{printf ("%d%s%d\n",beginning8,answer8,ending8);}}
       }
       goto endPrintLast;
              endPrintLast:
getchar();
}


There seems to be a Trojan Virus called ...wait let me try to run this... called:
generic!bq.bha

When I try to run this code, McAfee catches this trojan and my compiler, Dev C++ says:
Warning! Source code not compiled!

Any ideas on what to do? When I try running the
Hello World
program, it works fine.


[edit]It seems to be coming from the if statement, and the if statement only on lines 39-43.
Any suggestions?[/edit]
Last edited on
This should not a problem with the code.

Looks like your system is infected with virus. Please try to remove the virus using the anti virus program you have.

Apart from that, using 'goto' needs to be avoided whenever possible. Try to rewrite it without using goto (Try to use 'while' and achieve the same result).
I'd take a gander and say that the functions defined in your non standard header files could be acting upon some instance on the computer that's flagged as a trojan. The header files in question are:
1
2
3
#include "genlib.h"
#include "simpio.h"
#include "strlib.h" 


Another thing I noticed is that you're still using .h header files. This typically means your compiler is fairly dated. I am also going to assume that the functions included in the non standard header files are also included in some more up to date standard libraries. strlib.h looks like it might include functions from the cstring header file.

If you're determined to compile this, you can either disable McAfee, or set it into a "gaming" mode so that it only alerts you at critical problems (may still signal for a trojan though).
Okay guys, fixed it. I just deleted the header files and got new ones. Thanks Volatile Pulse.

Will fix those gotos also.
It's a .c file, maybe those .h includes are expected
Topic archived. No new replies allowed.