Saturday, May 17, 2014

replace-regular expression-vulnerability


REPLACE COMMAND
REGULAR EXPRESSION
REGEX
for insertion of a function in a existing request input, to avoid  sqlinjection vulnerabilities.


2. <%=Request(.[a-z0-9_"()]+)%> <%=rem_culp_char\((Request\1)\)%>
2. =trim\(Request(.[a-z0-9_"()]+)\) =trim\(rem_culp_char\((Request\1)\)\)
3. =Request(.[a-z0-9_"()]+) =rem_culp_char\((Request\1)\)
4. SINGLE SPACE Request.form(.[a-z0-9_"()]+) SINGLE SPACE  rem_culp_char\((Request.form\1)\)
5.   SINGLE SPACE Request(.[a-z0-9_"()]+) SINGLE SPACE  rem_culp_char\((Request\1)\)

inital space at item 4 & 5 in both search replace



function rem_culp_char(strWords)
dim newChars, i
newChars = strWords

If len(newChars) > 0 Then

newChars= replace(newChars, "select", "s-e-l-e-c-t",1,-1,1)
newChars= replace(newChars, "script", "s-c-r-i-p-t",1,-1,1)
newChars= replace(newChars, "insert", "i-n-s-e-r-t",1,-1,1)
newChars= replace(newChars, "drop", "d-r-o-p",1,-1,1)
newChars= replace(newChars, "delete", "d-e-l-e-t-e",1,-1,1)
newChars= replace(newChars, "xp_", "x-p_",1,-1,1)
newChars= replace(newChars, "<", " [Less than] ")
newChars= replace(newChars, ">", " [Greater than] ")
newChars= replace(newChars, "'", " [Single Quote] ")
newChars= replace(newChars, "(", "[")
newChars= replace(newChars, ")", "]")
newChars= replace(newChars, ";", ",")
newChars= replace(newChars, "=", " Equal To ")
newChars= replace(newChars, "--", "...")
newChars= replace(newChars, "|", " [PipeChar] ")
newChars= replace(newChars, "\", " [backslash] ")
rem_culp_char=newChars
End If
end function

Get Create table structure in Oracle

select dbms_metadata.get_ddl('TABLE','YOUR TABLE NAME','YOUR USER NAME') from dual

e.g.
select dbms_metadata.get_ddl ('TABLE','STAFF','SCOTT') from dual


output:
CREATE TABLE "SCOTT"."MASTER_STUDENT" ( "CO_SCH_ID" VARCHAR2(20), "OBJECTIVE" VARCHAR2(50), "CONTENT_COMMENTS" VARCHAR2(50), "MAT_COMMENTS" VARCHAR2(50), "PRESENTATIONS" VARCHAR2(50), "ARRANGEMENTS" VARCHAR2(50), "PHYSICAL" VARCHAR2(50), "RATING" FLOAT(126), "DELIVERY_COURSE" VARCHAR2(1000), "INFRASTRUCTURE" VARCHAR2(1000), "IDEA" VARCHAR2(1000), "TRAINEE_ID" VARCHAR2(35) NOT NULL ENABLE, "IOBJ" NUMBER(2,0) DEFAULT 0, "ICONTENT" NUMBER(2,0) DEFAULT 0, "IMATERIAL" NUMBER(2,0) DEFAULT 0, "IPRESENTATION" NUMBER(2,0) DEFAULT 0, "IARRANGEMENT" NUMBER(2,0) DEFAULT 0, "NEWTOPICSUGGEST" VARCHAR2(1000), "TEMPLATEID" NUMBER(1,0) DEFAULT 1, CONSTRAINT "CHECK_RATING" CHECK (rating between 0 and 10) ENABLE ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 53477376 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "MYTBLSPACE"

Followers