Seeking help to modify and update complete code to retrieve the password of the given IP address.

7 views
Skip to first unread message

Paul Wandendeya

unread,
Nov 22, 2023, 5:24:03 AM11/22/23
to kivy...@googlegroups.com
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button

class DomainLookupApp(App):
    def build(self):
        layout = BoxLayout(orientation='vertical')

        self.ip_input = TextInput(multiline=False)
        layout.add_widget(self.ip_input)

        self.result_label = Label()
        layout.add_widget(self.result_label)

        button = Button(text="Lookup", on_press=self.lookup_password)
        layout.add_widget(button)

        return layout

    def lookup_password(self, instance):
        ip_address = self.ip_input.text.strip()

        if self.validate_ip_address(ip_address):
            password = self.get_password(ip_address)
            if password is not None:
                self.result_label.text = f"IP Address: {ip_address}\nPassword: {password}"
            else:
                self.result_label.text = "No password found for the given IP address."
        else:
            self.result_label.text = "Invalid IP address."

    def validate_ip_address(self, ip_address):
        try:
            parts = ip_address.split('.')
            if len(parts) != 4:
                return False
            for part in parts:
                if not (0 <= int(part) <= 255):
                    return False
            return True
        except ValueError:
            return False

    def get_password(self, ip_address):
        # Replace the dictionary below with your own implementation to retrieve the password
        # based on the IP address

        # Example implementation:
        password_dict = {
            "15.197.20: "password1",
            "192.168.0.1": "password2",
            "10.0.0.1": "password3"
        }

        return password_dict.get(ip_address)

if __name__ == '__main__':
    DomainLookupApp().run() is there any one to help me with modifications and of app code to retrieve and display password of IP address number provided? 
Reply all
Reply to author
Forward
0 new messages