Initial commit
This commit is contained in:
		
							
								
								
									
										6
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					# How to setup (server) #
 | 
				
			||||||
 | 
					Take a look into the server folder. You _can_ use the pritunl src there to compile a guaranteed compartible version for this fake API (you'll still need the `setup.sh` script) or just download any version of pritunl server and try your luck.
 | 
				
			||||||
 | 
					Make sure your fake API has a valid SSL-cert (Let's encrypt is helpful).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# How to setup (api) #
 | 
				
			||||||
 | 
					Just copy the files inside the www folder to your webserver.
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								server/pritunl-1.29.2276.91.zip
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								server/pritunl-1.29.2276.91.zip
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										59
									
								
								server/setup.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										59
									
								
								server/setup.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,59 @@
 | 
				
			|||||||
 | 
					ORIG_API_SERVER='app.pritunl.com'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if hash dialog 2>/dev/null; then
 | 
				
			||||||
 | 
					    echo "Dialog found..."
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					    echo "Error: Package 'dialog' missing!"
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					if hash find 2>/dev/null; then
 | 
				
			||||||
 | 
					    echo "Find found..."
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					    echo "Error: Package 'find' missing!"
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					if hash sed 2>/dev/null; then
 | 
				
			||||||
 | 
					    echo "Sed found..."
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					    echo "Error: Package 'sed' missing!"
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					winX=80
 | 
				
			||||||
 | 
					winY=8
 | 
				
			||||||
 | 
					choices=$(dialog --menu "What can I do for you?" 0 $winX 0 "Change" "Changes the API endpoint to your choice" "Reset" "Changes the API endpoint back to $ORIG_API_SERVER" 2>&1 >/dev/tty)
 | 
				
			||||||
 | 
					ORIG_API_SERVER_ESCAPED=$(echo "$ORIG_API_SERVER" | sed -e 's/\./\\./g')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					get_fake_api() {
 | 
				
			||||||
 | 
					    FAKE_API_SERVER=$(dialog --title "Fake API address" --inputbox "Please enter the address from your faked API (with a valid HTTPS certificate). If you don't have one yourself, just use 'pritunl-api.simonmicro.de'." $winY $winX 2>&1 >/dev/tty)
 | 
				
			||||||
 | 
					    FAKE_API_SERVER_ESCAPED=$(echo "$FAKE_API_SERVER" | sed -e 's/\./\\./g')
 | 
				
			||||||
 | 
					    echo "Please wait. This can take up to several minutes..."
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					show_info() {
 | 
				
			||||||
 | 
					    dialog --msgbox "$1" $winY $winX
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for choice in $choices
 | 
				
			||||||
 | 
					do
 | 
				
			||||||
 | 
					    case $choice in
 | 
				
			||||||
 | 
					        Change)
 | 
				
			||||||
 | 
					            get_fake_api
 | 
				
			||||||
 | 
					            find /usr/lib/pritunl/lib/python2.7 -type f -print0 | xargs -0 sed -i "s/$ORIG_API_SERVER_ESCAPED/$FAKE_API_SERVER_ESCAPED/g"
 | 
				
			||||||
 | 
					            find /usr/share/pritunl/www/ -type f -print0 | xargs -0 sed -i "s/$ORIG_API_SERVER_ESCAPED/$FAKE_API_SERVER_ESCAPED/g"
 | 
				
			||||||
 | 
					            sleep 4
 | 
				
			||||||
 | 
					            show_info "Changed $ORIG_API_SERVER to $FAKE_API_SERVER. Please make sure to restart the pritunl daemon now."
 | 
				
			||||||
 | 
					            ;;
 | 
				
			||||||
 | 
					        Reset)
 | 
				
			||||||
 | 
					            echo "Make sure to REMOVE ANY FAKED SUBSCRIPTION KEY (not by entering an other command - just remove them). You have now 30 seconds time to hit CTRL+C and do this."
 | 
				
			||||||
 | 
					            sleep 30
 | 
				
			||||||
 | 
					            get_fake_api
 | 
				
			||||||
 | 
					            find /usr/lib/pritunl/lib/python2.7 -type f -print0 | xargs -0 sed -i "s/$FAKE_API_SERVER_ESCAPED/$ORIG_API_SERVER_ESCAPED/g"
 | 
				
			||||||
 | 
					            find /usr/share/pritunl/www/ -type f -print0 | xargs -0 sed -i "s/$FAKE_API_SERVER_ESCAPED/$ORIG_API_SERVER_ESCAPED/g"
 | 
				
			||||||
 | 
					            sleep 4
 | 
				
			||||||
 | 
					            show_info "Changed $FAKE_API_SERVER to $ORIG_API_SERVER. Please make sure to restart the pritunl daemon now."
 | 
				
			||||||
 | 
					            ;;
 | 
				
			||||||
 | 
					    esac
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exit 0
 | 
				
			||||||
							
								
								
									
										9
									
								
								www/enterprise.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								www/enterprise.css
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					.navbar-nav li {
 | 
				
			||||||
 | 
					    display: block !important;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					.container.links * {
 | 
				
			||||||
 | 
					    display: block !important;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					.modal-dialog .modal-body * {
 | 
				
			||||||
 | 
					    display: block;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										3544
									
								
								www/enterprise_plus.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3544
									
								
								www/enterprise_plus.css
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										126
									
								
								www/index.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										126
									
								
								www/index.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,126 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					header("Access-Control-Allow-Origin: *"); //Allow access from everywhere...
 | 
				
			||||||
 | 
					$code = 200;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Parse body (if possible)
 | 
				
			||||||
 | 
					$body = json_decode(file_get_contents('php://input'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Fake API
 | 
				
			||||||
 | 
					$result = 'UNDEFINED';
 | 
				
			||||||
 | 
					if(isset($_GET['path'])) {
 | 
				
			||||||
 | 
					    if(preg_match('/notification.*/', $_GET['path'])) {
 | 
				
			||||||
 | 
					        $result = new stdClass;
 | 
				
			||||||
 | 
					        $result->message = 'Fake API endpoint active and reachable under ' . $_SERVER['HTTP_HOST'] . ' (checked at ' . date('r') . ').';
 | 
				
			||||||
 | 
					        $result->vpn = false;
 | 
				
			||||||
 | 
					        $result->www = false;
 | 
				
			||||||
 | 
					    } else if(preg_match('/subscription.*/', $_GET['path'])) {
 | 
				
			||||||
 | 
					        $result = new stdClass;
 | 
				
			||||||
 | 
					        if(isset($body->license)) {
 | 
				
			||||||
 | 
					            //premium
 | 
				
			||||||
 | 
					            //enterprise
 | 
				
			||||||
 | 
					            //enterprise plus
 | 
				
			||||||
 | 
					            $license = null;
 | 
				
			||||||
 | 
					            $stylesheet = '* { color: rgb(20, 150, 20); } .dark * { color: rgb(40, 180, 40); }';
 | 
				
			||||||
 | 
					            if(preg_match('/.*premium/', $body->license)) {
 | 
				
			||||||
 | 
					                $license = 'premium';
 | 
				
			||||||
 | 
					            } else if(preg_match('/.*enterprise[^\w]/', $body->license)) {
 | 
				
			||||||
 | 
					                $license = 'enterprise';
 | 
				
			||||||
 | 
					                $stylesheet .= file_get_contents('enterprise.css');
 | 
				
			||||||
 | 
					            } else if(preg_match('/.*enterpriseplus/', $body->license)) {
 | 
				
			||||||
 | 
					                $license = 'enterprise_plus';
 | 
				
			||||||
 | 
					                $stylesheet .= file_get_contents('enterprise_plus.css');
 | 
				
			||||||
 | 
					                $stylesheet = preg_replace('/(.*display:.?)none.*/', '$1inline-block', $stylesheet);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $stylesheet .= '/* Generated for ' . $license . ' license */';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $state = null;
 | 
				
			||||||
 | 
					            if($license) { //The following only makes sense if you selected a license
 | 
				
			||||||
 | 
					                if(strpos($body->license, 'bad') !== false) {
 | 
				
			||||||
 | 
					                    $state = 'Bad';
 | 
				
			||||||
 | 
					                } else if(strpos($body->license, 'canceled') !== false) {
 | 
				
			||||||
 | 
					                    $state = 'canceled';
 | 
				
			||||||
 | 
					                }  else if(strpos($body->license, 'active') !== false) {
 | 
				
			||||||
 | 
					                    $state = 'Active';
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if($state == 'Active') {
 | 
				
			||||||
 | 
					                $result->active = $license != 'premium'; //if true the stylesheet ↓ will be activated. This will also hide some elements, so don't use it on premium users (which will have the minimal stylesheet)...
 | 
				
			||||||
 | 
					                $result->status = $state;
 | 
				
			||||||
 | 
					                $result->plan = $license;
 | 
				
			||||||
 | 
					                $result->quantity = 42;
 | 
				
			||||||
 | 
					                $result->amount = 42;
 | 
				
			||||||
 | 
					                $result->period_end = false;
 | 
				
			||||||
 | 
					                $result->trial_end = false;
 | 
				
			||||||
 | 
					                $result->cancel_at_period_end = false;
 | 
				
			||||||
 | 
					                $result->styles = new stdClass;
 | 
				
			||||||
 | 
					                $result->styles->etag = 42;
 | 
				
			||||||
 | 
					                $result->styles->last_modified = time();
 | 
				
			||||||
 | 
					                $result->styles->data = $stylesheet;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if($state == 'Canceled') {
 | 
				
			||||||
 | 
					                $result->active = false;
 | 
				
			||||||
 | 
					                $result->status = $state;
 | 
				
			||||||
 | 
					                $result->plan = $license;
 | 
				
			||||||
 | 
					                $result->quantity = 42;
 | 
				
			||||||
 | 
					                $result->amount = 42;
 | 
				
			||||||
 | 
					                $result->period_end = false;
 | 
				
			||||||
 | 
					                $result->trial_end = false;
 | 
				
			||||||
 | 
					                $result->cancel_at_period_end = false;
 | 
				
			||||||
 | 
					                $result->styles = new stdClass;
 | 
				
			||||||
 | 
					                $result->styles->etag = 42;
 | 
				
			||||||
 | 
					                $result->styles->last_modified = time();
 | 
				
			||||||
 | 
					                $result->styles->data = $stylesheet;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if($state == 'Bad' || $state == null) {
 | 
				
			||||||
 | 
					                $code = 470; //-> bad license
 | 
				
			||||||
 | 
					                $result->error_msg = 'As you wish.';
 | 
				
			||||||
 | 
					                $result->error = 'license_invalid';
 | 
				
			||||||
 | 
					                $result->active = false;
 | 
				
			||||||
 | 
					                $result->status = false;
 | 
				
			||||||
 | 
					                $result->plan = null;
 | 
				
			||||||
 | 
					                $result->quantity = 0;
 | 
				
			||||||
 | 
					                $result->amount = 0;
 | 
				
			||||||
 | 
					                $result->period_end = true;
 | 
				
			||||||
 | 
					                $result->trial_end = true;
 | 
				
			||||||
 | 
					                $result->cancel_at_period_end = null;
 | 
				
			||||||
 | 
					                $result->styles = new stdClass;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if($state == null) {
 | 
				
			||||||
 | 
					                $result->error_msg = 'Unknown command. Use ["bad" | "canceled" | "active"] ["premium" | "enterprise" | "enterpriseplus"].';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $result = new stdClass;
 | 
				
			||||||
 | 
					            $result->ERROR = 'BAD REQUEST';
 | 
				
			||||||
 | 
					            $code = 400;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } else if(preg_match('/checkout.*/', $_GET['path'])) {
 | 
				
			||||||
 | 
					        $result = array();
 | 
				
			||||||
 | 
					        $result['zipCode'] = false;
 | 
				
			||||||
 | 
					        $result['allowRememberMe'] = false;
 | 
				
			||||||
 | 
					        $result['image'] = 'https://objectstorage.us-ashburn-1.oraclecloud.com/n/pritunl8472/b/pritunl-static/o/logo_stripe.png';
 | 
				
			||||||
 | 
					        $result['key'] = 'pk_live_plmoOl3lS3k5dMNQViZWGfVR'; //Stolen store key from official API
 | 
				
			||||||
 | 
					        $result['plans'] = array();
 | 
				
			||||||
 | 
					        $result['plans']['premium'] = array();
 | 
				
			||||||
 | 
					        $result['plans']['premium']['amount'] = 42;
 | 
				
			||||||
 | 
					        $result['plans']['enterprise'] = array();
 | 
				
			||||||
 | 
					        $result['plans']['enterprise']['amount'] = 42;
 | 
				
			||||||
 | 
					        $result['plans']['enterprise_plus'] = array();
 | 
				
			||||||
 | 
					        $result['plans']['enterprise_plus']['amount'] = 42;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					header('Content-Type: application/json');
 | 
				
			||||||
 | 
					http_response_code($code);
 | 
				
			||||||
 | 
					echo json_encode($result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if(false) {
 | 
				
			||||||
 | 
					    //Log request
 | 
				
			||||||
 | 
					    file_put_contents('access.log', "\n" . date('r') . ":\t" . json_encode(array('head' => getallheaders(), 'body' => file_get_contents('php://input'), 'get' => $_GET, 'post' => $_POST, 'answer_code' => $code, 'answer' => $result)) . "\n", FILE_APPEND);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //GET operator to clear log file
 | 
				
			||||||
 | 
					    if(isset($_GET['clear']))
 | 
				
			||||||
 | 
					        file_put_contents('access.log', '');
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					?>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user