Exemple #1
0
def delete_from_booking(request, id):
    destination = Destination.objects.get(id=id)
    item_tobe_deleted = BookedDest.objects.get(destination=id,
                                               user_mac=gma(),
                                               paid=False)
    cost = destination.price

    user_cart = Cart.objects.get(user_mac=gma(), ordered=False)
    alldests = user_cart.dest.all()
    if len(alldests) == 1:
        newtotal = 0
        user_cart.total = newtotal
        user_cart.dest.remove(destination.id)
        user_cart.delete()
        item_tobe_deleted.delete()
        messages.info(request, 'You have cleared your cart')
        return redirect('welcome')
    else:
        newtotal = user_cart.total - cost
        user_cart.total = newtotal
        user_cart.dest.remove(destination.id)
        user_cart.save()
        item_tobe_deleted.delete()

        messages.info(request, 'Item successfully deleted from your cart')
        return redirect('welcome')
Exemple #2
0
def process_payment(request):
    #Converting Kenya shillings to US Dollars
    API_KEY = settings.FIXER_ACCESS_KEY
    url = "http://data.fixer.io/api/latest?access_key=" + API_KEY + "&symbols=KES,USD"
    response = requests.request("GET", url)
    html = response.json()
    kes = html['rates']['KES']
    usd = html['rates']['USD']
    final_usd = kes / usd

    #Checking out
    try:
        book_dest = BookedDest.objects.filter(user_mac=gma(), paid=False)
    except BookedDest.DoesNotExist:
        book_dest = []

    try:
        user_cart = Cart.objects.get(user_mac=gma(), ordered=False)
        print('******************USER CART OBJECT***************')

        print(user_cart)
        # setting mac address to profile
        current_user = Profile.objects.get(editor=request.user)
        user_cart.user_mac = current_user.user_mac
        current_user.save()
    except Cart.DoesNotExist:
        user_cart = []

    total_in_usd = user_cart.total / final_usd
    list_of_dests = []
    for dest in book_dest:
        list_of_dests.append(dest.destination.destname)

    host = request.get_host()
    paypal_dict = {
        'business':
        settings.PAYPAL_RECEIVER_EMAIL,
        'amount':
        '%.2f' % total_in_usd,
        'item_name':
        '{}'.format(list_of_dests),
        'invoice':
        str(random.randint(00000, 99999)),
        'currency_code':
        'USD',
        'notify_url':
        'http://{}{}'.format(host,
                             '-gdgdj-travel-kahndbfh-gshdnhdjf-ksndshdj'),
        'return_url':
        'http://{}{}'.format(host, '/payment-done/'),
        'cancel_return':
        'http://{}{}'.format(host, '/payment-cancelled/'),
    }
    form = PayPalPaymentsForm(initial=paypal_dict)
    #End of paypal
    return render(request, 'checkout.html', {
        "form": form,
        "book_dest": book_dest,
        "cart": user_cart
    })
Exemple #3
0
    def func_register():
        print register_name.get()
        print register_mail.get()
        print register_password.get()
        print register_tel.get()
        print(gma())

        cnx = mysql.connector.connect(user='******',
                                      password='',
                                      host='127.0.0.1',
                                      database='social',
                                      use_pure=False)
        cursor = cnx.cursor()
        add_employee = (
            "INSERT INTO users "
            "(name, email, password, mac_address, tel, usertype, key_licence, date_start, date_now, created_at, updated_at)"
            "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)")
        data_employee = (register_name.get(), register_mail.get(),
                         register_password.get(), gma(), register_tel.get(),
                         'client', '0', date(2020, 8,
                                             9), '1', datetime.now().date(),
                         datetime.now().date())

        cursor.execute(add_employee, data_employee)
        emp_no = cursor.lastrowid

        print(emp_no)
        cnx.commit()
        cursor.close()
        cnx.close()
        newWindow2.destroy()

        driver = webdriver.Firefox()
        driver.get("http://localhost:8000/add_licence")
Exemple #4
0
def file_upload(request):
    if request.method=='POST':        
        file_x=request.FILES['myfile']     
        cloudinary.uploader.destroy(gma())                                    
        file_name=gma()                
        cloudinary.uploader.upload(file_x,resource_type="video",public_id="transcribe_x/"+file_name)        
        messages.info(request, 'Successfully Uploaded you file. Scroll down and hover Transcribe button for magic.')                
        return render(request,'index.html',{"uploaded_file_url":"yes"})                     

    return redirect("home")
Exemple #5
0
def addtowishlist(request, id):
    dest = Destination.objects.get(id=id)
    try:
        wishlist_exists = Wishlist.objects.get(user_mac=gma(),
                                               destination=dest)
        messages.info(request, "This destination is already in your wishlist")
        return redirect("displaywishlist")

    except Wishlist.DoesNotExist:
        new_wishlist = Wishlist(destination=dest, user_mac=gma())
        new_wishlist.save()
        messages.info(request,
                      "The destination has been added to your wishlist")
        return redirect('displaywishlist')
Exemple #6
0
 def __init__(self, logging):
     self._HostMac = gma()
     self._HostIp = None
     self._TargetMac = None
     self._TargetIp = None
     self._Interfaces = self.fetchInterfaces()
     self.logging = logging
Exemple #7
0
def checkKey(en_code, key, mode, iv):
    #把暗碼解成明碼
    print("checkKey")
    print(en_code, key, mode, iv)
    try:
        de_code = decryp_str(en_code, key, mode, iv)

    except:
        print("except")
        return en_code
    print("de_code=" + de_code)
    if de_code != '':
        print("code=", de_code)
        code = de_code[0:4]
        code += '-'
        code += de_code[4:6]
        code += '-'
        code += de_code[6:8]
        today = str(datetime.datetime.today().strftime("%Y-%m-%d"))
        machine = de_code[8:]
        if machine == str(gma()):

            #code1='2021-04-20'
            if code >= today:
                return True
            else:
                return "EXPIRED CODE"
        else:
            return "Error: On Different Device."
    else:
        return "MISSING CODE"
def get_mac_address():
    '''
    Get mac address
    :return: mac address
    '''
    address = gma().replace(':', '')
    return address
Exemple #9
0
    def game_is_initiated(self) -> bool:
        if not self.p2_exists():
            if self.__p1 == self.get_mac():
                print('You are already player1. Wait for player 2...')
                self.__can_i_update = False
                return False

            while True:
                inp = input(
                    'There is no 2nd player, would you like to play? (y/n)')
                if inp == 'y':
                    self.set_p2(gma())
                    break
                elif inp == 'n':
                    sys.exit(0)
                else:
                    pass

            self.assign_roles()

            color = 'White' if self.__w == 'p2' else 'Black'
            print('Assigning roles, you are %s' % color)
            self.inc_seq()
            return False
        else:
            print('Game is loading..')
            return True
Exemple #10
0
def cheeser():
    #Look after the original MAC
    original = (gma())
    #Randomize a new address
    charset = "0123456789abcdef"
    randommac = "00"
    for i in range(5):
        randommac += ":" +\
                        random.choice(charset)\
                        + random.choice(charset)
    #do the terminal commands
    def subproc():
        subprocess.call(["sudo", "ifconfig", "wlp3s0", "down"])
        subprocess.call(
            ["sudo", "ifconfig", "wlp3s0", "hw", "ether", randommac])
        subprocess.call(["sudo", "ifconfig", "wlp3s0", "up"])

    subproc()
    print("Your MAC has been cheesed. New MAC:" + randommac)
    print("The new MAC will expire in 60 seconds and be reverted.")
    print("KEEP THIS PROGRAM OPEN.")
    time.sleep(60)
    subprocess.call(["sudo", "ifconfig", "wlp3s0", "down"])
    subprocess.call(["sudo", "ifconfig", "wlp3s0", "hw", "ether", original])
    subprocess.call(["sudo", "ifconfig", "wlp3s0", "up"])
    print("Old MAC restored:" + original)
    print("Safe to close.")
Exemple #11
0
def lobby():
    
    d = open("banner-hub.txt","r")
    asciii = "".join(d.readlines())
    print(colorText(asciii))
    hub = input(colorText("[[cyan]][ 1 ] Information about an ip adress \n[ 2 ] Start Metasploit \n[ 3 ] Password  \n[ 4 ] View Mac Adress \n\n[ 99 ] Exit \n\n[ ? ] Choice : "))
    try :
        val = int(hub)
    except ValueError :
        print(colorText("[[red]][-] Error, choose an option between 1 and 4 "))
        lobby()
    if val == 99 :
        sys.exit()
    if val >= 5 :
        print(colorText("[[red]][-] Error, choose an option between 1 and 4"))
        lobby()
    if val == 1 :
        lobby1()
    if val == 2 :
        os.system('clear')
        print(colorText("[[red]][+] LAUNCHING METASPLOIT... "))
        os.system('msfconsole')
    if val == 3 : 
        lobby2()
    if val == 4 :
        print("\n",gma())
        lobby()
Exemple #12
0
def displaycart(request):
    try:
        cart_items = Cart.objects.filter(user_mac=gma(), ordered=False)
    except Cart.DoesNotExist:
        cart_items = []

    return render(request, 'cartdisplay.html', {"cartitems": cart_items})
Exemple #13
0
def payment_done(request):
    user_cart = Cart.objects.get(user_mac=gma(), ordered=False)
    book_dest = BookedDest.objects.filter(user_mac=gma(), paid=False)
    user_cart.ordered = True
    user_cart.receipt_no = uuid.uuid4().hex[:6].upper()
    user_cart.payment_method = "Paypal"
    user_cart.save()

    for dest in book_dest:
        dest.paid = True
        dest.save()
    messages.info(
        request,
        'Your booking has been made successfully.Thank you for choosing Travel Agency'
    )
    return redirect('welcome')
Exemple #14
0
def displaywishlist(request):
    try:
        wishlist_items = Wishlist.objects.filter(user_mac=gma())
    except Wishlist.DoesNotExist:
        wishlist_items = []

    return render(request, 'wishlist.html', {"wishitems": wishlist_items})
Exemple #15
0
def MacIp(request):
    host_name = socket.gethostname()
    host_ip = socket.gethostbyname(host_name)
    a = "Host-Name = " + host_name
    b = "   ,   IP Address = " + host_ip
    d = "   ,   MAC Address = " + gma() + "MilliSecond"
    c = [a, b, d]
    return HttpResponse(c)
Exemple #16
0
def get_cpu_usage():
    """Get CPU usage per second

    Returns: point object from influxdb-client
    """
    cpu_usage = cpu_percent(interval=1)
    return influxdb_client.Point("cpu").field("CPU Percent", cpu_usage).tag(
        "host_name",
        gma() + "")
 def hashing_mac(self):
     from getmac import get_mac_address as gma
     import hashlib
     import os
     mac = gma()
     mac = str(mac).encode('utf8')
     machash = hashlib.sha256()
     machash.update(mac)
     self.hash_mac = machash.hexdigest()
Exemple #18
0
 def vm_check():
     from getmac import get_mac_address as gma
     mac=gma()
     x = requests.get('https://api.macvendors.com/'+mac)
     if x.text =='Microsoft Corporation' or x.text=='Xensource, Inc.' or x.text=='VMware, Inc.' :
         vm_test=1
     else:
         vm_test=0
     if vm_test==1:
         exit()
Exemple #19
0
def get_network_data():
    """Get network information since system starts

    Returns: point object from influxdb-client
    """
    network_data = net_io_counters()
    return influxdb_client.Point("network")\
        .field("uploading", network_data.bytes_sent)\
        .field("downloading", network_data.bytes_recv)\
        .tag("host_name", gma() + "")
Exemple #20
0
def booking_summary(request):
    try:
        book_dest = BookedDest.objects.filter(user_mac=gma(), paid=False)
    except BookedDest.DoesNotExist:
        book_dest = []

    try:
        cart_items = Cart.objects.filter(user_mac=gma(), ordered=False)
    except Cart.DoesNotExist:
        cart_items = []

    if len(book_dest) < 1:
        messages.info(request, 'You have not added anything to your cart.')
        return redirect('welcome')
    else:
        return render(request, 'bookingsummary.html', {
            "book_dest": book_dest,
            "cartitems": cart_items
        })
Exemple #21
0
def make_booking(request):
    dest_id = request.POST.get("dest_id")
    user_dest = Destination.objects.get(id=dest_id)
    print('****************USER_DESTINATION******************')
    print(user_dest)
    try:
        usercart = Cart.objects.get(user_mac=gma(), ordered=False)
        if usercart.ordered == False:
            destcart = usercart.dest.all()
            all_items = []
            for onedest in destcart:
                all_items.append(onedest.destname)

            if user_dest.destname in all_items:
                messages.info(request, 'Destination already exist.')
                return redirect('welcome')
            else:
                new_booking = BookedDest(destination=user_dest, user_mac=gma())
                new_booking.save()
                sub_total = user_dest.price
                usercart.dest.add(user_dest.id)
                usercart.total += sub_total
                usercart.save()
                messages.info(
                    request,
                    'The destination successfully added to cart.Continue exploring or click booking summary to proceed to payment'
                )
                return redirect('welcome')

    except Cart.DoesNotExist:
        new_booking = BookedDest(destination=user_dest, user_mac=gma())
        new_booking.save()

        sub_total = user_dest.price
        new_cart = Cart(user_mac=gma(), total=sub_total)
        new_cart.save()
        new_cart.dest.add(user_dest)
        new_cart.save()
        messages.info(
            request,
            'The destination successfully added to your cart.Continue exploring or click booking summary to proceed to payment'
        )
        return redirect('welcome')
Exemple #22
0
def get_swap_memory_used():
    """Get swap memory used

    Returns: point object from influxdb-client
    """
    swap_used = swap_memory()
    return influxdb_client.Point("memory").field("Swap memory used",
                                                 swap_used.percent).tag(
                                                     "host_name",
                                                     gma() + "")
Exemple #23
0
def getHash256MAC():
    #mac = get_mac()
    mac = gma()
    mac = str(mac).encode('utf8')
    machash = hashlib.sha256()
    machash.update(mac)

    #print(machash.hexdigest())
    arquivoHash = open("hashmac", "w+")
    arquivoHash.write(machash.hexdigest())
Exemple #24
0
 def __init__(self, gps_rate=None):
     # initialize objects
     self.stop_blink = threading.Event()
     self._gui = gui.GUI()
     self._buttons = buttons.Buttons(on_green=self.green_callback,
                                     on_blue=self.blue_callback,
                                     on_red=self.red_callback)
     self.rs = RobotState()
     print("The first state in the state machine is: %s" % self.rs.state)
     print("Mac Address: " + gma())
     self._gps = gpsCode.GPS()
Exemple #25
0
def get_battery_level():
    """Get battery level

    Returns: point object from influxdb-client
    """
    battery_level = sensors_battery()
    if battery_level is not None:
        return influxdb_client.Point("sensors").field(
            "Battery Level",
            battery_level.percent).tag("host_name",
                                       gma() + "")
Exemple #26
0
def deletefromwishlist(request, id):
    try:
        dest_del = Wishlist.objects.get(user_mac=gma(), destination=id)
        dest_del.delete()
        messages.info(
            request,
            "The destination has been successfully deleted from your wishlist")

        return redirect('displaywishlist')
    except ObjectDoesNotExist:
        raise Http404()
    def __init__(self, parent=None):
        super(ClientMqtt, self).__init__()
        threading.Thread.__init__(self)
        self.nom = "DefaultClientMqtt"
        self.mac = gma()
        self.serveur = "127.0.0.1"
        self.port = 8080
        self.client = paho.Client(self.nom)

        self.Debug = True
        self.__stop_event = False
Exemple #28
0
def get_virtual_memory():
    """Get virtual memory information

    Returns: point object from influxdb-client
    """
    memory = virtual_memory()
    return influxdb_client.Point("memory")\
        .field("total_virtual_memory", memory.total)\
        .field("virtual_memory_used", memory.used)\
        .field("virtual_memory_free", memory.free)\
        .tag("host_name", gma() + "")
Exemple #29
0
 def check_security_access(self):
     try:
         if self.header.get("security", None) == 'mac':
             current_mac = gma().upper()
             if self.header["target"] == current_mac or self.header[
                     "target"] == "FF:FF:FF:FF:FF:FF":
                 return True, ""
             else:
                 return False, "Message Not Intended for you"
         return True, ""
     except:
         return False, "Missing Data in Image"
Exemple #30
0
    def __init__(self, main):
        QWidget.__init__(self)
        self.main = main

        home = str(Path.home())
        self.home_dir = home + "/calomni_software"

        if not os.path.isdir(self.home_dir):
            os.mkdir(self.home_dir)

        if not os.path.isdir(self.home_dir + "/.config/"):
            os.mkdir(self.home_dir + "/.config/")

        if not os.path.isdir(self.home_dir + "/environment/"):
            os.mkdir(self.home_dir + "/environment/")

        if not os.path.isdir(self.home_dir + "/.tmp/"):
            os.mkdir(self.home_dir + "/.tmp/")

        if not os.path.isdir(self.home_dir + "/reports/"):
            os.mkdir(self.home_dir + "/reports/")

        if not os.path.isdir(self.home_dir + "/logs/"):
            os.mkdir(self.home_dir + "/logs/")

        self.api = Api(self)
        self.log = Log(self)
        self.mac = gma()
        if self.mac is None:
            self.log.error(
                "Cannot retrieve mac address. Please make sure your pc has properly setup",
                None, True, exit)
            return
        self.token = hashlib.md5(self.mac.encode("utf-8")).hexdigest()
        self.log.info("MAC: %s. Token: %s" % (self.mac, self.token))

        self.login_screen = Login(self)
        self.rh_screen = RhScreen(self)
        self.sh_screen = ShScreen(self)

        if self.api.bearer:
            user = self.api.login_bearer()
            if user:
                if user['role'] == 'rh':
                    self.rh_screen.show()
                    self.rh_screen.initializing()

                elif user['role'] == 'sh':
                    self.sh_screen.show()
                    self.sh_screen.initializing()

        else:
            self.login_screen.show()