This repository was archived by the owner on May 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathalien.php
More file actions
executable file
·72 lines (63 loc) · 1.91 KB
/
Copy pathalien.php
File metadata and controls
executable file
·72 lines (63 loc) · 1.91 KB
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
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
<title>Challenge 16</title>
<center>
<body bgcolor="black" style="margin-left:35px">
<img src="text_replacer.png">
<font color="white">
</head>
<body>
<h2>
<hr>
<?php
include_once dirname(__FILE__).'/../../init.php';
session_start();
require_once(HACKADEMIC_PATH."pages/challenge_monitor.php");
$monitor->update(CHALLENGE_INIT, $_GET);
$_SESSION['init'] = true;
?>
<form method="get" id="replacer">
Enter the text: <br/><textarea name="text" cols="30" rows="4"></textarea><br/><br/>
Enter the word to find: <input id="pattern" type="text" name="pattern"/><br/><br>
Enter the word to replace with: <input type="text" name="replace_with"/><br/><br>
<input type="button" value="Replace Text" onclick="addslashes();" />
</form >
<script>
function addslashes()
{
document.getElementById("pattern").value='/'+document.getElementById('pattern').value+'/';
document.getElementById("replacer").submit();
}
</script>
<?php
if(isset($_GET['text']) and isset($_GET['pattern']) and isset($_GET['replace_with']) )
{
list($empty, $pattern, $modifier) = split('/',$_GET['pattern']);
$end='/';
$replace=$_GET['replace_with'];
if($modifier=='i')
{
$end='/i';
}
else if($modifier=='e')
{
$replace= preg_replace('/\s+/', '', $replace);
$replace= preg_replace('/;+/', '', $replace);
if($replace=='system("location")' or $replace=="system('location')" or $replace=='shell_exec("location")' or $replace=="shell_exec('location')" or $replace=='exec("location")' or $replace=="exec('location')")
{
$replace="90.0000° S, 0.0000° W";
}
else
{
$replace="you don't have permission to execute this particular command";
}
}
echo 'Your replaced text:<br/>';
echo preg_replace('/'.$pattern.$end, $replace, $_GET['text']);
}
?>
</center>
</body>
</html>