Advertisement
Sweetening

Untitled

Oct 16th, 2024
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. import logging
  2. from selenium import webdriver
  3. from selenium.webdriver.common.by import By
  4. import pyshark
  5. import threading
  6.  
  7. # Configure logging
  8. logging.basicConfig(filename='session_debug.log', level=logging.DEBUG,
  9. format='%(asctime)s %(levelname)s %(message)s')
  10.  
  11. # Setup WebDriver for Facebook call session
  12. def start_session_debugger(fb_call_url):
  13. try:
  14. logging.info("Starting session debugger for URL: %s", fb_call_url)
  15.  
  16. # Set up WebDriver (Chrome in this case)
  17. options = webdriver.ChromeOptions()
  18. options.add_argument('--no-sandbox')
  19. options.add_argument('--disable-dev-shm-usage')
  20. options.add_argument('--headless') # Run in headless mode
  21. driver = webdriver.Chrome(options=options)
  22.  
  23. driver.get(fb_call_url)
  24.  
  25. logging.info("Opened Facebook group call page.")
  26.  
  27. # Assuming that you'd want to log some page elements or session data
  28. try:
  29. peer_id = driver.find_element(By.XPATH, "//input[@name='peer_id']").get_attribute('value')
  30. logging.info(f"Peer ID: {peer_id}")
  31. except Exception as e:
  32. logging.error(f"Failed to retrieve peer_id: {str(e)}")
  33.  
  34. # Other session parameters can be captured here similarly
  35.  
  36. except Exception as e:
  37. logging.error(f"Error in session debugger: {str(e)}")
  38. finally:
  39. driver.quit()
  40.  
  41. # Network Packet Capture using Pyshark
  42. def capture_network_packets(interface='eth0'):
  43. logging.info("Starting network capture on interface: %s", interface)
  44. capture = pyshark.LiveCapture(interface=interface)
  45.  
  46. try:
  47. for packet in capture.sniff_continuously(packet_count=100):
  48. if 'IP' in packet:
  49. logging.debug(f"Packet: {packet['IP'].src} -> {packet['IP'].dst}")
  50. except Exception as e:
  51. logging.error(f"Error capturing packets: {str(e)}")
  52.  
  53. # Run both the session debugger and network capture in parallel
  54. if __name__ == "__main__":
  55. fb_call_url = 'https://www.facebook.com/groupcall/ROOM:7847047172021551/?call_id=928793448&has_video=true'
  56.  
  57. # Start session debugger in a separate thread
  58. session_thread = threading.Thread(target=start_session_debugger, args=(fb_call_url,))
  59. session_thread.start()
  60.  
  61. # Start network packet capture in the main thread
  62. capture_network_packets(interface='eth0')
  63.  
  64. session_thread.join()
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement