Issues (1191)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
include 'php/jodel-web.php';
4
5
6
if(isset($_GET['pw']))
7
{
8
	setcookie('JodelAdminPassword', $_GET['pw'], time()+60*60*24*365*10);
9
	error_log('admin password saved for [' . $_SERVER ['HTTP_USER_AGENT'] . ']');
10
	header('Location: ' . $baseUrl . 'admin.php');
11
	exit;
12
}
13
else if(isset($_GET['voterPw']))
14
{
15
	setcookie('JodelVoterPassword', $_GET['voterPw'], time()+60*60*24*365*10);
16
	error_log('voter password saved for [' . $_SERVER ['HTTP_USER_AGENT'] . ']');
17
	header('Location: ' . $baseUrl);
18
	exit;
19
}
20
21
if(isUserAdmin())
22
{
23
	$userIsAdmin = true;
24
	$userIsVoter = true;
25
	$votesRemaining = 'Unlimited';
26
}
27
else if(isUserVoter())
28
{
29
	$userIsAdmin = false;
30
	$userIsVoter = true;
31
32
	$result = $db->query("SELECT user_token, remaining_votes FROM users WHERE user_token = '" . $_COOKIE['JodelVoterPassword'] . "'");
33
	if($result->num_rows > 0)
34
	{
35
		$row = $result->fetch_assoc();
36
		$votesRemaining = $row['remaining_votes'];
37
	}
38
	else
39
	{
40
		error_log('Hard error: isUser voter, get remaining votes in admin.php');
41
	}
42
}
43
else
44
{
45
	error_log($_SERVER['REMOTE_ADDR']  . ' used a wrong voterPw / pw on admin.php');
46
	die();
47
}
48
49
50
if($userIsAdmin && isset($_POST['createAccount']) && $_POST['createAccount'])
51
{
52
	$newJodelAccount = new JodelAccount();
53
}
54
55
if($userIsAdmin && isset($_POST['createVoter']) && $_POST['createVoter'])
56
{
57
	//insert voter into db
58
	$db = new DatabaseConnect();
59
    $result = $db->query("INSERT INTO users (user_token, remaining_votes, device_uid, rights)
60
                    VALUES ('" 	. $db->escape_string($_POST['user_token'])
61
                    	. "','" . $db->escape_string($_POST['remaining_votes'])
62
                    	. "','" . $db->escape_string($_POST['device_uid'])
63
                    	. "','" . $db->escape_string($_POST['rights']) . "')");
64
    
65 View Code Duplication
    if($result === false){
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
66
            $error = db_error();
67
            error_log($error);
68
            error_log("Adding Voter failed: (" . $result->errno . ") " . $result->error);
69
    } 
70
}
71
72
//Vote
73
/*
74
if($userIsVoter && isset($_POST['vote']) && isset($_POST['postId']) && isset($_POST['quantity']))
75
{
76
	$i = 0;
77
	$result = $db->query("SELECT access_token, device_uid FROM accounts WHERE device_uid NOT IN (SELECT device_uid FROM votes WHERE postId = '" . $_POST['postId'] . "')");
78
79
	if($result->num_rows > 0)
80
	{
81
		// output data of each row
82
		while(($row = $result->fetch_assoc()) && $i < $_POST['quantity'])
83
		{
84
			$jodelAccount = new JodelAccount($row['device_uid']);
85
86
			if($jodelAccount->votePostId($_POST['postId'], $_POST['vote']))
87
			{
88
				$i++;
89
			}
90
		}
91
	}
92
	else
93
	{
94
		error_log("Error: 0 results");
95
	}
96
}
97
*/
98
99
?>
100
<!DOCTYPE html>
101
<html lang="en">
102
	<head>
103
		<title>Backend - JodelBlue WebClient</title>
104
		
105
		<meta charset="utf8">
106
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
107
		<meta http-equiv="x-ua-compatible" content="ie=edge">
108
		
109
		<meta name="description" content="JodelBlue is a WebClient for the Jodel App. No registration required! Browse Jodels all over the world. Send your own Jodels or upvote others.">
110
		<meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client">
111
		
112
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">
113
				<link rel="stylesheet" href="<?php echo $baseUrl;?>css/font-awesome.min.css">
114
		<link rel="stylesheet" href="<?php echo $baseUrl;?>style.css" type="text/css">
115
		
116
		<link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico">
117
		<link rel="icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico">
118
		<link rel="icon" type="image/gif" href="<?php echo $baseUrl;?>img/favicon/favicon.gif">
119
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon.png">
120
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon.png">
121
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57">
122
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60">
123
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72">
124
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76">
125
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114">
126
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120">
127
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128">
128
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144">
129
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152">
130
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180">
131
		<link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-precomposed.png">
132
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-16x16.png" sizes="16x16">
133
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-32x32.png" sizes="32x32">
134
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-96x96.png" sizes="96x96">
135
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-160x160.png" sizes="160x160">
136
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-192x192.png" sizes="192x192">
137
		<link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-196x196.png" sizes="196x196">
138
		<meta name="msapplication-TileImage" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> 
139
		<meta name="msapplication-TileColor" content="#5682a3"> 
140
		<meta name="msapplication-navbutton-color" content="#5682a3"> 
141
		<meta name="application-name" content="JodelBlue"/> 
142
		<meta name="msapplication-tooltip" content="JodelBlue"/> 
143
		<meta name="apple-mobile-web-app-title" content="JodelBlue"/> 
144
		<meta name="msapplication-square70x70logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-70x70.png"> 
145
		<meta name="msapplication-square144x144logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> 
146
		<meta name="msapplication-square150x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-150x150.png"> 
147
		<meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x150.png"> 
148
		<meta name="msapplication-square310x310logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x310.png"> 
149
	</head>
150
	
151
	<body>
152
		<header>
153
			<nav class="navbar navbar-full navbar-dark navbar-fixed-top">
154
				<div class="container">					
155
					<h1>
156
						<a href="./admin.php" class="spinnable">						
157
							JodelBlue <i class="fa fa-refresh fa-1x"></i>
158
						</a>
159
					</h1>					
160
				</div>
161
			</nav>
162
		</header>
163
		
164
		<div class="mainContent container">		
165
			<div class="row">
166
				<article class="topContent col-12 col-sm-12">
167
					<content id="posts" class="adminpanel">
168
						<?php if($userIsAdmin) { ?>
169
							<div class="row">
170
								<div class="col-md-12">
171
									<h2>Account management</h2>
172
								</div>
173
174
								<div class="col-md-4">
175
										<h3>User accounts</h3>
176
										<form method="post">
177
											<div>
178
												<?php
179
													$result = $db->query("SELECT COUNT(*) FROM accounts");
180
													echo $result->fetch_row()[0];
181
													$db->close();
182
												?>
183
												accounts in the database
184
											</div>
185
											<button type="submit" name="createAccount" value="TRUE">Create new Account</button>
186
										</form>
187
								</div>
188
189
								<div class="col-md-8">
190
									<h3>Create Voter</h3>
191
									<form method="post">
192
										<div class="form-group">
193
											<label for="user_token">User token</label>
194
											<input type="text" class="form-control" id="user_token" name="user_token" placeholder="user_token" required="true">
195
										</div>
196
										<div class="form-group">
197
											<label for="remaining_votes">Remaining votes</label>
198
											<input type="number" class="form-control" name="remaining_votes" placeholder="remaining_votes" required="true">
199
										</div>
200
										<div class="form-group">
201
											<label for="device_uid">Device Uid</label>
202
											<input type="text" class="form-control" name="device_uid" placeholder="device_uid" required="true">
203
										</div>
204
										<div class="form-group">
205
											<label for="rights">Rights</label>
206
											<input type="text" class="form-control" name="rights" placeholder="rights" required="true">
207
										</div>
208
										<button type="submit" name="createVoter" value="TRUE">Create new Voter</button>
209
									</form>
210
								</div>							
211
							</div>
212
						<hr>
213
						<?php
214
						}
215
216
						if($userIsVoter) {
217
						?>
218
							<div class="row">								
219
								<div class="col-12 col-sm-12">
220
								<h2>Voting (<?php echo $votesRemaining;?> votes remaining)</h2>
221
									<form>
222
										<div class="form-group">
223
											<label for="quantityDelay">Quantity</label>
224
											<input placeholder="quantity" class="form-control" id="quantityDelay" type="number" name="quantity">
225
										</div>
226
										<div class="form-group">
227
											<label for="minDelay">Minimum delay</label>
228
											<div class="input-group">
229
												<input placeholder="min interval" class="form-control" id="minDelay" value="<?php echo $config['minInterval'];?>" type="number" name="min">
230
												<span class="input-group-addon">seconds</span>
231
											</div>
232
										</div>
233
										<div class="form-group">
234
											<label for="maxDelay">Maximum delay</label>
235
											<div class="input-group">
236
												<input placeholder="max interval" class="form-control" id="maxDelay" value="<?php echo $config['maxInterval'];?>" type="number" name="max">
237
												<span class="input-group-addon">seconds</span>
238
											</div>
239
										</div>
240
										<div class="form-group">
241
											<label for="postIdDelay">Post Id</label>
242
											<input placeholder="postId" class="form-control" id="postIdDelay" value="<?php if(isset($_GET['postId'])) echo $_GET['postId'];?>" type="text" name="postId">
243
										</div>
244
										<div class="row">
245
											<div class="col-6 col-xs-6"><button type="button" name="vote" value="up" class="half" onclick="voteWithAjax('up');">Upvote</button></div>
246
											<div class="col-6 col-xs-6"><button type="button" name="vote" value="down" class="half" onclick="voteWithAjax('down');">Downvote</button></div>
247
										</div>
248
									</form>
249
									<progress id="progressDelay" value="0" max="100"></progress>
250
									<div id="ResponseMessage"></div>
251
									<div id="ResponseCaptcha"></div>
252
								</div>
253
							</div>
254
						<?php } ?>
255
					</content>
256
				</article>
257
			</div>
258
		</div>
259
		
260
		
261
		<!-- jQuery, Tether, Bootstrap JS and own-->
262
		<script
263
			  src="https://code.jquery.com/jquery-3.1.1.min.js"
264
			  integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
265
			  crossorigin="anonymous"></script>
266
	    <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
267
	    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
268
	    <script src="<?php echo $baseUrl;?>js/jQueryEmoji.js"></script>
269
	    <script src="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.1.1/ekko-lightbox.min.js" integrity="sha256-1odJPEl+KoMUaA1T7QNMGSSU/r5LCKCRC6SL8P0r2gY=" crossorigin="anonymous"></script>
270
271
		<script>
272
			//delayed voting
273
			var rekData;
274
			function voteWithAjax(type)
275
			{
276
				var id = $("#postIdDelay").val();
277
				var quantity = parseInt($("#quantityDelay").val());
278
				var minTime = parseFloat($("#minDelay").val());
279
				var maxTime = parseFloat($("#maxDelay").val());	
280
				var data = {"vote": type,
281
						   "id":id,
282
							"i": 1,
283
						   "quantity":quantity,
284
						   "minTime":minTime,
285
						   "maxTime":maxTime};
286
				
287
				$("#progressDelay").attr("max", quantity);
288
				$("#progressDelay").val(0);
289
				if (minTime > maxTime)
290
				{
291
					$("#ResponseMessage").html("min interval is greater than max interval");
292
					
293
				}
294
				else if (id == "")
295
				{
296
					$("#ResponseMessage").html("please enter a postId");
297
				}
298
				else if (isNaN(quantity))
299
				{
300
					$("#ResponseMessage").html("please enter a valid quantity of votes");
301
				}
302
				else 
303
				{
304
					voteRek(data);
305
				}
306
			}
307
			
308
			function voteRek(data)
309
			{
310
				$.ajax({
311
				  type: "POST",
312
				  url: "<?php echo $baseUrl;?>vote-ajax.php",
313
				  data: {"vote" : data["vote"],
314
						 "postId" : data["id"]},
315
				  success: function(result){
316
					  $("#progressDelay").val(data["i"]);
317
					  var response;
318
					  try 
319
					  {
320
						response = JSON.parse(result);
321
					  } catch (e) {
322
						//voteRek(data);
323
					  }
324
					  if (response["success"] != true)
325
					  {
326
						  $("#ResponseMessage").html(response["message"]);
327
						  if (response["captcha"] != null) {
328
							  rekData = data;
329
							  $("#ResponseCaptcha").append( "<div id='captchaWrapper_" + data["i"] + "'><form><p>Check all images with Coons on it (Coons look like <img style=\"height: 1.0em; width: unset;\" src=\"img/coon.png\">).</p><img src='" + response["captcha"]["image_url"] + "' style='width:100%'><div class='captchaWrapper'><input id='box_0' type='checkbox'><input id='box_1' type='checkbox'><input id='box_2' type='checkbox'><input id='box_3' type='checkbox'><input id='box_4' type='checkbox'><input id='box_5' type='checkbox'><input id='box_6' type='checkbox'><input id='box_7' type='checkbox'><input id='box_8' type='checkbox'></div><button type=\"button\" onclick=\"verifyAccount(" + data["i"] + ", '" + response["captcha"]["key"] + "' , '" + response["deviceUid"] + "');\">Verify</button></form></div>");
330
							  //verifyAccount(data["i"], response["captcha"]["key"], response["deviceUid"]);
331
						  }
332
					  }
333
					  else if (data["i"] < data["quantity"])
334
					  {
335
						  $("#ResponseMessage").html(data["i"] + " of " + data["quantity"]);
336
						  data["i"] += 1;
337
						  setTimeout(function(){voteRek(data)}, getRandomFloat(data["minTime"],data["maxTime"])*1000);
338
					  } else {
339
						  $("#ResponseMessage").html(data["quantity"] + " votes completed");
340
					  }
341
				  }
342
				});
343
			}
344
			
345
			function verifyAccount(id, key, deviceUid)
346
			{
347
				var solution = "";
348
				for (i=0; i<9; i++) {
349
					var box = $("#box_"+i);
350
					if (box.is(':checked') == true)
351
					{
352
						if (solution != "")
353
						{
354
							solution += "-" + i;
355
						}
356
						else 
357
						{
358
							solution = i;
359
						}
360
361
					}
362
				}
363
				console.log(solution);
364
				$.ajax({
365
				  type: "POST",
366
				  url: "<?php echo $baseUrl;?>vote-ajax.php?solution=" + solution + "&key="+key,
367
				  data: {"deviceUid" : deviceUid},
368
				  success: function(result){
369
					  var response = JSON.parse(result);
370
					  console.log("Verification = "+response["success"])
371
					  $("#captchaWrapper_"+id).remove();
372
					  voteRek(rekData);
373
				  }
374
				});
375
			}
376
			
377
			function getRandomFloat(min, max)
378
			{
379
			  return Math.floor(Math.random() * (max - min)) + min;
380
			}
381
382
		</script>
383
	</body>
384
</html>