-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path32.php
96 lines (73 loc) · 2.16 KB
/
32.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<pre><?php
/*
vigenère cipher
--> use keyword 'clift'
--> from character 5 onwards use the result - autokey
https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
*/
$orig = 'tpdwxjw\'viyegmzbecfvpcqtuwdinpfhzvvfadzbkfoevcnseozxffdlvrdo\'jwsjkzllxwapfrvhuaqz';
$irregularities = array();
$step1 = array();
for($i=0; $i<strlen($orig); $i++) {
if(preg_match("/^[a-z]+$/", $orig[$i]) == 1) {
$step1[] = $orig[$i];
} else {
$irregularities[$i] = $orig[$i];
}
}
echo 'orig: '.$orig.'
irregularities found at the following positions:
';
foreach($irregularities AS $key => $value) {
echo $key.': "'.$value.'"
';
}
echo '
step1: '.implode(' ', $step1).'
';
$alphabet = 'abcdefghijklmnopqrstuvwxyz';
$keyword = 'clift';
$step2 = array();
for($i=0; $i<count($step1); $i++) {
if($i < strlen($keyword)) {
$currentKeyCharacter = $keyword[($i%strlen($keyword))];
} else {
$currentKeyCharacter = $step2[($i - strlen($keyword))];
}
$targetPos = strpos($alphabet, $step1[$i]) - strpos($alphabet, $currentKeyCharacter);
if($targetPos>=strlen($alphabet)) {
$targetPos = $targetPos - strlen($alphabet);
} elseif($targetPos<0) {
$targetPos = $targetPos + strlen($alphabet);
}
$step2[] = $alphabet[$targetPos];
}
echo 'step2: '.implode(' ', $step2).'
';
$step3 = implode(' ', $step2);
echo 'step3: '.strrev($step3).'
';
// Put the irregularities back in
$outputTMP = '';
$counter = 0;
foreach($step2 AS $key => $value) {
if(isset($irregularities[$counter])) {
$outputTMP .= " ".$irregularities[$counter];
$counter ++;
}
if($outputTMP != '') {
$outputTMP .= ' ';
}
$outputTMP .= $value;
$counter ++;
}
echo '
out: '.$outputTMP.'
rev: '.strrev($outputTMP);
?>
<hr /><hr />
solution:
i compromised this user's password through network monitoring to hack into shimomura's server
answer to the solution:
Lile Elam
</pre>