Blog Archive

ShareThis

Showing posts with label ALGORITHMS AND CODING. Show all posts
Showing posts with label ALGORITHMS AND CODING. Show all posts

Thursday, January 13, 2011

Script injection vulnerability

Shoubhik Bose January 14 at 12:30am
http://www.mywbut.com/answer.php
go there ( after loggin in) and click on the question,
"What are the differences between function and interrupt? "
I had inserted,


into the text area..

and now the page gets redirected to the page i found appropriate ! haha.. !

I am actually creating a forum on nseccse3.appspot.com , a similar thing happened by mistake..
I had to write some code(a java class)to get a work around(its secure now from scripts.)..

had a good experience! ;-P

This is script injection !

The problem was displaying "<" and ">", once the code was stripped of these, it could no longer run... ! Hence, they were the most crucial tokens in the whole code.. !

FLASHBACK: Earlier I had written code to insert &nbsp for whitespace and
for "\n" into the string !

 So,  here i needed the appropriate representation of  '<' and '>' barring

 http://www.alanwood.net/demos/symbol.html#s2200

Job was simple,

replace '<' with " < "
and
repace '>' with "  > "

but
had to be kept intact..
so,

 if( i+3 < s.length() ){
                  if( s.charAt(i+1) == 'b' && s.charAt(i+2)=='r' && s.charAt(i+3)=='>'){
                            processed+="
";
                            i+=3;
                            continue;
                    }
     }

Job done..!
the full code is here:

http://pastebin.com/7ZHXzM5p

Good day !

Friday, November 12, 2010


na(n)
11
20
30
42
510
64
740
892
9352
10724
112680
1214200
1373712
14365596
152279184
1614772512
1795815104
18666090624
194968057848
2039029188884
21314666222712
222691008701644
2324233937684440
24227514171973736
252207893435808352
2622317699616364044

Saturday, September 18, 2010

Bellman-Ford



SOURCE from where I read it

MATRIX CHAIN MULTIPLICATION !!! (go to the link post here for the source code)

DYNAMIC PROGRAMMING:

Problem:

Given
dimensions:

p0,p1,p2,... pn

determine the “multiplication sequence” that minimizes
the number of scalar multiplications in computing
A1,A2,A3..An . where Ai has a dimension p(i-1) X p(i)

That is, determine how to parenthisize
the multiplications.



SOURCE CODE FOR THE SOLUTION TO THIS PROBLEM


/* I HAVE ALLOCATED MEMORY STATICALLY FOR TESTING PURPOSES.

P[ ]={5,4,6,2,7}

means:

matrices of order 5 X 4 , 4 X 6 , 6 X 2 , 2 X 7

check http://www.cs.ust.hk/~dekai/271/notes/L12/L12.pdf

for the dry run and the detailed algorithm.

the Cpp program for the above problem is posted here

*/