File tree Expand file tree Collapse file tree 2 files changed +74
-1
lines changed Expand file tree Collapse file tree 2 files changed +74
-1
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ #include <string.h>
3
+ #include <stdlib.h>
4
+
5
+ #define FIRSTCHAROFFSET 129
6
+ #define LINELENGTH 35
7
+ #define NEWLINEOFFSET 21
8
+ #define LINECOUNT 6
9
+
10
+ #define BUFFLEN 1024
11
+
12
+ char flag [] = " _ \n"
13
+ " //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n"
14
+ " // / \n"
15
+ " // / \n"
16
+ " // / \n"
17
+ " // / \n"
18
+ " // / \n"
19
+ " // / \n"
20
+ " //___________________________________/ \n"
21
+ " // \n"
22
+ " // \n"
23
+ " // \n"
24
+ " // \n"
25
+ " // \n"
26
+ " // \n" ;
27
+
28
+ void placeInFlag (char * flag , char * str ){
29
+ char * ptr = flag + FIRSTCHAROFFSET ;
30
+ char * lastInLine = ptr + LINELENGTH ;
31
+ size_t charRemaining = strlen (str );
32
+ size_t linesDone = 0 ;
33
+ while (charRemaining > 0 && linesDone < LINECOUNT ){
34
+ if (ptr == lastInLine ){
35
+ ptr += NEWLINEOFFSET ;
36
+ lastInLine += NEWLINEOFFSET + LINELENGTH ;
37
+ linesDone ++ ;
38
+ continue ;
39
+ }
40
+ ptr [0 ] = str [0 ];
41
+ ptr ++ ;
42
+ str ++ ;
43
+ charRemaining -- ;
44
+ }
45
+
46
+ }
47
+
48
+
49
+
50
+ int main (int argc , char * * argv ){
51
+ setbuf (stdout , NULL );
52
+
53
+ size_t flagSize = strlen (flag ) + 1 ; //need to remember null terminator
54
+ char * input = (char * )malloc (sizeof (char ) * flagSize );
55
+ input [flagSize - 1 ] = '\x0' ;
56
+ char * tempFlag = (char * )malloc (sizeof (char ) * flagSize );
57
+ while (1 ){
58
+ strncpy (tempFlag , flag , flagSize );
59
+ tempFlag [flagSize - 1 ] = '\x0' ;
60
+ fgets (input , flagSize , stdin );
61
+ char * temp = strchr (input , '\n' );
62
+ if (temp != NULL ){
63
+ temp [0 ] = '\x0' ;
64
+ }
65
+
66
+ placeInFlag (tempFlag , input );
67
+ printf (tempFlag );
68
+ }
69
+ free (tempFlag );
70
+ free (input );
71
+ }
72
+
73
+
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ def hex_to_bin(repr: str, sep: int = 8) -> str:
101
101
return int_to_bin (n , sep )
102
102
103
103
104
- def scan_sourcecode (path ):
104
+ def scan_file (path ):
105
105
with tempfile .NamedTemporaryFile () as tmp :
106
106
os .chdir (os .path .dirname (os .path .abspath (__file__ )))
107
107
proc = subprocess .run ('flawfinder --context --html %s' % path , stdout = tmp , shell = True )
You can’t perform that action at this time.
0 commit comments