Skip to content

Commit 1ebc4fd

Browse files
author
Nick Galbreath
committed
English
1 parent 63e3a5c commit 1ebc4fd

6 files changed

+41
-41
lines changed

Diff for: src/libinjection_html5.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ int libinjection_h5_next(h5_state_t* hs)
106106
static int h5_is_white(char ch)
107107
{
108108
/*
109-
* \t = htab = 0x09
109+
* \t = horizontal tab = 0x09
110110
* \n = newline = 0x0A
111-
* \v = vtab = 0x0B
111+
* \v = vertical tab = 0x0B
112112
* \f = form feed = 0x0C
113113
* \r = cr = 0x0D
114114
*/
@@ -458,7 +458,7 @@ static int h5_state_attribute_value_quote(h5_state_t* hs, char qchar)
458458
TRACE();
459459

460460
/* skip initial quote in normal case.
461-
* dont do this is pos == 0 since it means we have started
461+
* don't do this "if (pos == 0)" since it means we have started
462462
* in a non-data state. given an input of '><foo
463463
* we want to make 0-length attribute name
464464
*/

Diff for: src/libinjection_sqli.c

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2012,2013 Nick Galbreath
2+
* Copyright 2012,2016 Nick Galbreath
33
44
* BSD License -- see COPYING.txt for details
55
*
@@ -187,11 +187,11 @@ static int char_is_white(char ch) {
187187
/* ' ' space is 0x32
188188
'\t 0x09 \011 horizontal tab
189189
'\n' 0x0a \012 new line
190-
'\v' 0x0b \013 verical tab
190+
'\v' 0x0b \013 vertical tab
191191
'\f' 0x0c \014 new page
192192
'\r' 0x0d \015 carriage return
193193
0x00 \000 null (oracle)
194-
0xa0 \240 is latin1
194+
0xa0 \240 is Latin-1
195195
*/
196196
return strchr(" \t\n\v\f\r\240\000", ch) != NULL;
197197
}
@@ -290,7 +290,7 @@ static void st_clear(stoken_t * st)
290290
static void st_assign_char(stoken_t * st, const char stype, size_t pos, size_t len,
291291
const char value)
292292
{
293-
/* done to elimiate unused warning */
293+
/* done to eliminate unused warning */
294294
(void)len;
295295
st->type = (char) stype;
296296
st->pos = pos;
@@ -398,7 +398,7 @@ static size_t parse_eol_comment(struct libinjection_sqli_state * sf)
398398
}
399399
}
400400

401-
/** In Ansi mode, hash is an operator
401+
/** In ANSI mode, hash is an operator
402402
* In MYSQL mode, it's a EOL comment like '--'
403403
*/
404404
static size_t parse_hash(struct libinjection_sqli_state * sf)
@@ -1526,7 +1526,7 @@ int libinjection_sqli_fold(struct libinjection_sqli_state * sf)
15261526
continue;
15271527
} else if ((sf->tokenvec[left].type == TYPE_BAREWORD || sf->tokenvec[left].type == TYPE_VARIABLE) &&
15281528
sf->tokenvec[left+1].type == TYPE_LEFTPARENS && (
1529-
/* TSQL functions but common enough to be collumn names */
1529+
/* TSQL functions but common enough to be column names */
15301530
cstrcasecmp("USER_ID", sf->tokenvec[left].val, sf->tokenvec[left].len) == 0 ||
15311531
cstrcasecmp("USER_NAME", sf->tokenvec[left].val, sf->tokenvec[left].len) == 0 ||
15321532

@@ -1549,7 +1549,7 @@ int libinjection_sqli_fold(struct libinjection_sqli_state * sf)
15491549

15501550
/* pos is the same
15511551
* other conversions need to go here... for instance
1552-
* password CAN be a function, coalese CAN be a function
1552+
* password CAN be a function, coalesce CAN be a function
15531553
*/
15541554
sf->tokenvec[left].type = TYPE_FUNCTION;
15551555
continue;
@@ -1813,7 +1813,7 @@ int libinjection_sqli_fold(struct libinjection_sqli_state * sf)
18131813
* 1,-sin(1) --> 1 (1)
18141814
* Here, just do
18151815
* 1,-sin(1) --> 1,sin(1)
1816-
* just remove unary opartor
1816+
* just remove unary operator
18171817
*/
18181818
st_copy(&sf->tokenvec[left+1], &sf->tokenvec[left+2]);
18191819
pos -= 1;
@@ -2016,7 +2016,7 @@ int libinjection_sqli_blacklist(struct libinjection_sqli_state* sql_state)
20162016
}
20172017

20182018
/*
2019-
* return TRUE if sqli, false is benign
2019+
* return TRUE if SQLi, false is benign
20202020
*/
20212021
int libinjection_sqli_not_whitelist(struct libinjection_sqli_state* sql_state)
20222022
{
@@ -2030,10 +2030,10 @@ int libinjection_sqli_not_whitelist(struct libinjection_sqli_state* sql_state)
20302030

20312031
if (tlen > 1 && sql_state->fingerprint[tlen-1] == TYPE_COMMENT) {
20322032
/*
2033-
* if ending comment is contains 'sp_password' then it's sqli!
2033+
* if ending comment is contains 'sp_password' then it's SQLi!
20342034
* MS Audit log apparently ignores anything with
2035-
* 'sp_password' in it. Unable to find primary refernece to
2036-
* this "feature" of SQL Server but seems to be known sqli
2035+
* 'sp_password' in it. Unable to find primary reference to
2036+
* this "feature" of SQL Server but seems to be known SQLi
20372037
* technique
20382038
*/
20392039
if (my_memmem(sql_state->s, sql_state->slen,
@@ -2052,7 +2052,7 @@ int libinjection_sqli_not_whitelist(struct libinjection_sqli_state* sql_state)
20522052

20532053
if (sql_state->fingerprint[1] == TYPE_UNION) {
20542054
if (sql_state->stats_tokens == 2) {
2055-
/* not sure why but 1U comes up in Sqli attack
2055+
/* not sure why but 1U comes up in SQLi attack
20562056
* likely part of parameter splitting/etc.
20572057
* lots of reasons why "1 union" might be normal
20582058
* input, so beep only if other SQLi things are present
@@ -2077,7 +2077,7 @@ int libinjection_sqli_not_whitelist(struct libinjection_sqli_state* sql_state)
20772077

20782078
/*
20792079
* for fingerprint like 'nc', only comments of /x are treated
2080-
* as SQL... ending comments of "--" and "#" are not sqli
2080+
* as SQL... ending comments of "--" and "#" are not SQLi
20812081
*/
20822082
if (sql_state->tokenvec[0].type == TYPE_BAREWORD &&
20832083
sql_state->tokenvec[1].type == TYPE_COMMENT &&
@@ -2087,7 +2087,7 @@ int libinjection_sqli_not_whitelist(struct libinjection_sqli_state* sql_state)
20872087
}
20882088

20892089
/*
2090-
* if '1c' ends with '/x' then it's sqli
2090+
* if '1c' ends with '/x' then it's SQLi
20912091
*/
20922092
if (sql_state->tokenvec[0].type == TYPE_NUMBER &&
20932093
sql_state->tokenvec[1].type == TYPE_COMMENT &&
@@ -2110,13 +2110,13 @@ int libinjection_sqli_not_whitelist(struct libinjection_sqli_state* sql_state)
21102110
if (sql_state->tokenvec[0].type == TYPE_NUMBER &&
21112111
sql_state->tokenvec[1].type == TYPE_COMMENT) {
21122112
if (sql_state->stats_tokens > 2) {
2113-
/* we have some folding going on, highly likely sqli */
2113+
/* we have some folding going on, highly likely SQLi */
21142114
sql_state->reason = __LINE__;
21152115
return TRUE;
21162116
}
21172117
/*
21182118
* we check that next character after the number is either whitespace,
2119-
* or '/' or a '-' ==> sqli.
2119+
* or '/' or a '-' ==> SQLi.
21202120
*/
21212121
ch = sql_state->s[sql_state->tokenvec[0].len];
21222122
if ( ch <= 32 ) {
@@ -2138,7 +2138,7 @@ int libinjection_sqli_not_whitelist(struct libinjection_sqli_state* sql_state)
21382138
}
21392139

21402140
/*
2141-
* detect obvious sqli scans.. many people put '--' in plain text
2141+
* detect obvious SQLi scans.. many people put '--' in plain text
21422142
* so only detect if input ends with '--', e.g. 1-- but not 1-- foo
21432143
*/
21442144
if ((sql_state->tokenvec[1].len > 2)
@@ -2174,7 +2174,7 @@ int libinjection_sqli_not_whitelist(struct libinjection_sqli_state* sql_state)
21742174
}
21752175

21762176
/*
2177-
* not sqli
2177+
* not SQLi
21782178
*/
21792179
sql_state->reason = __LINE__;
21802180
return FALSE;
@@ -2183,8 +2183,8 @@ int libinjection_sqli_not_whitelist(struct libinjection_sqli_state* sql_state)
21832183
streq(sql_state->fingerprint, "1&1") ||
21842184
streq(sql_state->fingerprint, "1&v") ||
21852185
streq(sql_state->fingerprint, "1&s")) {
2186-
/* 'sexy and 17' not sqli
2187-
* 'sexy and 17<18' sqli
2186+
/* 'sexy and 17' not SQLi
2187+
* 'sexy and 17<18' SQLi
21882188
*/
21892189
if (sql_state->stats_tokens == 3) {
21902190
sql_state->reason = __LINE__;
@@ -2240,7 +2240,7 @@ int libinjection_is_sqli(struct libinjection_sqli_state * sql_state)
22402240
size_t slen = sql_state->slen;
22412241

22422242
/*
2243-
* no input? not sqli
2243+
* no input? not SQLi
22442244
*/
22452245
if (slen == 0) {
22462246
return FALSE;

Diff for: src/libinjection_sqli.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct libinjection_sqli_token {
5353

5454
/* count:
5555
* in type 'v', used for number of opening '@'
56-
* but maybe unsed in other contexts
56+
* but maybe used in other contexts
5757
*/
5858
int count;
5959

@@ -118,7 +118,7 @@ struct libinjection_sqli_state {
118118
/*
119119
* fingerprint pattern c-string
120120
* +1 for ending null
121-
* Mimimum of 8 bytes to add gcc's -fstack-protector to work
121+
* Minimum of 8 bytes to add gcc's -fstack-protector to work
122122
*/
123123
char fingerprint[8];
124124

Diff for: src/libinjection_xss.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static stringtype_t BLACKATTR[] = {
150150
, { "DATASRC", TYPE_BLACK } /* IE */
151151
, { "DYNSRC", TYPE_ATTR_URL } /* Obsolete img attribute */
152152
, { "FILTER", TYPE_STYLE } /* Opera, SVG inline style */
153-
, { "FORMACTION", TYPE_ATTR_URL } /* HTML5 */
153+
, { "FORMACTION", TYPE_ATTR_URL } /* HTML 5 */
154154
, { "FOLDER", TYPE_ATTR_URL } /* Only on A tags, IE-only */
155155
, { "FROM", TYPE_ATTR_URL } /* SVG */
156156
, { "HANDLER", TYPE_ATTR_URL } /* SVG Tiny, Opera */
@@ -166,7 +166,7 @@ static stringtype_t BLACKATTR[] = {
166166
};
167167

168168
/* xmlns */
169-
/* xml-stylesheet > <eval>, <if expr=> */
169+
/* `xml-stylesheet` > <eval>, <if expr=> */
170170

171171
/*
172172
static const char* BLACKATTR[] = {
@@ -240,8 +240,8 @@ static int cstrcasecmp_with_null(const char *a, const char *b, size_t n)
240240
}
241241

242242
/*
243-
* Does an HTML encoded binary string (const char*, lenght) start with
244-
* a all uppercase c-string (null terminated), case insenstive!
243+
* Does an HTML encoded binary string (const char*, length) start with
244+
* a all uppercase c-string (null terminated), case insensitive!
245245
*
246246
* also ignore any embedded nulls in the HTML string!
247247
*
@@ -275,7 +275,7 @@ static int htmlencode_startswith(const char *a, const char *b, size_t n)
275275
}
276276

277277
if (cb == 10) {
278-
/* always ignore vtab characters in user input */
278+
/* always ignore vertical tab characters in user input */
279279
/* who allows this?? */
280280
continue;
281281
}
@@ -340,9 +340,9 @@ static attribute_t is_black_attr(const char* s, size_t len)
340340
return TYPE_NONE;
341341
}
342342

343-
/* javascript on.* */
343+
/* JavaScript on.* */
344344
if ((s[0] == 'o' || s[0] == 'O') && (s[1] == 'n' || s[1] == 'N')) {
345-
/* printf("Got javascript on- attribute name\n"); */
345+
/* printf("Got JavaScript on- attribute name\n"); */
346346
return TYPE_BLACK;
347347
}
348348

@@ -384,7 +384,7 @@ static int is_black_url(const char* s, size_t len)
384384
/*
385385
* HEY: this is a signed character.
386386
* We are intentionally skipping high-bit characters too
387-
* since they are not ascii, and Opera sometimes uses UTF8 whitespace.
387+
* since they are not ASCII, and Opera sometimes uses UTF-8 whitespace.
388388
*
389389
* Also in EUC-JP some of the high bytes are just ignored.
390390
*/
@@ -433,7 +433,7 @@ int libinjection_is_xss(const char* s, size_t len, int flags)
433433
/*
434434
* IE6,7,8 parsing works a bit differently so
435435
* a whole <script> or other black tag might be hiding
436-
* inside an attribute value under HTML5 parsing
436+
* inside an attribute value under HTML 5 parsing
437437
* See http://html5sec.org/#102
438438
* to avoid doing a full reparse of the value, just
439439
* look for "<". This probably need adjusting to

Diff for: src/reader.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ int main(int argc, const char *argv[])
224224
int flag_quiet = FALSE;
225225

226226
/*
227-
* only print postive results
227+
* only print positive results
228228
* with invert, only print negative results
229229
*/
230230
int flag_true = FALSE;

Diff for: src/testdriver.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ int read_file(const char* fname, int flags, int testtype)
188188
g_actual[0] = '\0';
189189
if (testtype == 0) {
190190
/*
191-
* print sqli tokenization only
191+
* print SQLi tokenization only
192192
*/
193193
libinjection_sqli_init(&sf, copy, slen, flags);
194194
libinjection_sqli_callback(&sf, NULL, NULL);
@@ -209,7 +209,7 @@ int read_file(const char* fname, int flags, int testtype)
209209
}
210210
} else if (testtype == 2) {
211211
/**
212-
* test sqli detection
212+
* test SQLi detection
213213
*/
214214
char buf[100];
215215
issqli = libinjection_sqli(copy, slen, buf);
@@ -218,7 +218,7 @@ int read_file(const char* fname, int flags, int testtype)
218218
}
219219
} else if (testtype == 3) {
220220
/*
221-
* test html5 tokenization only
221+
* test HTML 5 tokenization only
222222
*/
223223

224224
h5_state_t hs;
@@ -233,7 +233,7 @@ int read_file(const char* fname, int flags, int testtype)
233233
*/
234234
sprintf(g_actual, "%d", libinjection_xss(copy, slen));
235235
} else {
236-
fprintf(stderr, "Got stange testtype value of %d\n", testtype);
236+
fprintf(stderr, "Got strange testtype value of %d\n", testtype);
237237
assert(0);
238238
}
239239

0 commit comments

Comments
 (0)