컴퓨터에서 방문한 모든 URL을 기록하는 프로그램을 작성하려고하지만 독립형이므로 Fiddler2 확장이 아닙니다. 거기에 내가 이미 내 응용 프로그램에 포함시킬 수있는 라이브러리가 있습니까 (C# .Net로 작성하려고했으나 Windows 용으로 사용하는 한 유연합니다). 그렇지 않다면 적어도 HTTP 패킷에서 정보를 읽는 것을 촉진 할 수있는 것이 있습니까? 나는 즉시 그 URL을 분석하고 싶다. 감사.Windows 용 독립 실행 형 URL 로거 작성 방법
1
A
답변
1
이렇게하려면 분석중인 컴퓨터에서 트래픽을 감지해야합니다.
이렇게하려면 pcap 라이브러리를 사용하십시오. 더 높은 수준의 프로그래밍 언어를 C# (또는 Java)로 사용하고자 할 수 있으므로 pcap 라이브러리 사용을 용이하게하는 많은 래퍼가 있습니다. Java에는 (이후에는 익숙하기 때문에) jNetPcap이라는 래퍼가 있습니다. 오픈 소스이며 좋은 문서를 가지고 있습니다. 어떤 NIC의 트래픽을 감지하려면 아래 예를 참조하십시오.
package org.jnetpcap.examples;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.jnetpcap.Pcap;
import org.jnetpcap.PcapIf;
import org.jnetpcap.packet.PcapPacket;
import org.jnetpcap.packet.PcapPacketHandler;
/**
* Here is the output generated by this example :
*
* Network devices found:
* #0: \Device\NPF_{BC81C4FC-242F-4F1C-9DAD-EA9523CC992D} [Intel(R) PRO/100 VE]
* #1: \Device\NPF_{E048DA7F-D007-4EEF-909D-4238F6344971} [VMware Virtual Ethernet Adapter]
* #2: \Device\NPF_{5B62B373-3EC1-460D-8C71-54AA0BF761C7} [VMware Virtual Ethernet Adapter]
* #3: \Device\NPF_GenericDialupAdapter [Adapter for generic dialup and VPN capture]
*
* Choosing 'Intel(R) PRO/100 VE) ' on your behalf:
* Received packet at Tue Nov 03 18:52:42 EST 2009 caplen=1362 len=1362 jNetPcap rocks!
* Received packet at Tue Nov 03 18:52:45 EST 2009 caplen=82 len=82 jNetPcap rocks!
* Received packet at Tue Nov 03 18:52:45 EST 2009 caplen=145 len=145 jNetPcap rocks!
* Received packet at Tue Nov 03 18:52:45 EST 2009 caplen=62 len=62 jNetPcap rocks!
* Received packet at Tue Nov 03 18:52:45 EST 2009 caplen=164 len=164 jNetPcap rocks!
* Received packet at Tue Nov 03 18:52:45 EST 2009 caplen=62 len=62 jNetPcap rocks!
* Received packet at Tue Nov 03 18:52:45 EST 2009 caplen=54 len=54 jNetPcap rocks!
* Received packet at Tue Nov 03 18:52:45 EST 2009 caplen=1073 len=1073 jNetPcap rocks!
* Received packet at Tue Nov 03 18:52:45 EST 2009 caplen=1514 len=1514 jNetPcap rocks!
* Received packet at Tue Nov 03 18:52:45 EST 2009 caplen=279 len=279 jNetPcap rocks!
*/
public class ClassicPcapExample {
/**
* Main startup method
*
* @param args
* ignored
*/
public static void main(String[] args) {
List<PcapIf> alldevs = new ArrayList<PcapIf>(); // Will be filled with NICs
StringBuilder errbuf = new StringBuilder(); // For any error msgs
/***************************************************************************
* First get a list of devices on this system
**************************************************************************/
int r = Pcap.findAllDevs(alldevs, errbuf);
if (r == Pcap.NOT_OK || alldevs.isEmpty()) {
System.err.printf("Can't read list of devices, error is %s", errbuf
.toString());
return;
}
System.out.println("Network devices found:");
int i = 0;
for (PcapIf device : alldevs) {
String description =
(device.getDescription() != null) ? device.getDescription()
: "No description available";
System.out.printf("#%d: %s [%s]\n", i++, device.getName(), description);
}
PcapIf device = alldevs.get(0); // We know we have atleast 1 device
System.out
.printf("\nChoosing '%s' on your behalf:\n",
(device.getDescription() != null) ? device.getDescription()
: device.getName());
/***************************************************************************
* Second we open up the selected device
**************************************************************************/
int snaplen = 64 * 1024; // Capture all packets, no trucation
int flags = Pcap.MODE_PROMISCUOUS; // capture all packets
int timeout = 10 * 1000; // 10 seconds in millis
Pcap pcap =
Pcap.openLive(device.getName(), snaplen, flags, timeout, errbuf);
if (pcap == null) {
System.err.printf("Error while opening device for capture: "
+ errbuf.toString());
return;
}
/***************************************************************************
* Third we create a packet handler which will receive packets from the
* libpcap loop.
**************************************************************************/
PcapPacketHandler<String> jpacketHandler = new PcapPacketHandler<String>() {
public void nextPacket(PcapPacket packet, String user) {
System.out.printf("Received packet at %s caplen=%-4d len=%-4d %s\n",
new Date(packet.getCaptureHeader().timestampInMillis()),
packet.getCaptureHeader().caplen(), // Length actually captured
packet.getCaptureHeader().wirelen(), // Original length
user // User supplied object
);
}
};
/***************************************************************************
* Fourth we enter the loop and tell it to capture 10 packets. The loop
* method does a mapping of pcap.datalink() DLT value to JProtocol ID, which
* is needed by JScanner. The scanner scans the packet buffer and decodes
* the headers. The mapping is done automatically, although a variation on
* the loop method exists that allows the programmer to sepecify exactly
* which protocol ID to use as the data link type for this pcap interface.
**************************************************************************/
pcap.loop(10, jpacketHandler, "jNetPcap rocks!");
/***************************************************************************
* Last thing to do is close the pcap handle
**************************************************************************/
pcap.close();
}
}
이 예제는 jNetPcap 웹 사이트에서 추출한 것입니다. 보시다시피 nextPacket() 메서드를 사용자 정의하여 사용자가 원하는 것을 만들면됩니다.
간단하게 될 것이라고 : 내가 도왔
public void nextPacket(PcapPacket packet, String user) {
Http http = new Http();
if (packet.hasHeader(http)) {
System.out.printf("Received packet at %s: %s\n",
new Date(packet.getCaptureHeader().timestampInMillis()),
http.Request.valueOf("Host")
);
}
희망.
관련 문제
- 1. 독립 실행 형 (Windows) JRE입니까?
- 2. Windows 7에서 AntlrWorks2 독립 실행 형 실행
- 3. 독립 실행 형 DirectoryServices.DirectoryEntry()
- 4. 독립 실행 형 VC++ 컴파일러
- 5. SSRS와 독립 실행 형 Windows 응용 프로그램 용 Crystal Reports
- 6. WCF 용 독립 실행 형 응용 프로그램
- 7. 구조 WCF 용 독립 실행 형 WPF
- 8. 크롬의 독립 실행 형 버전 (개발 용)
- 9. ActivePerl 용 독립 실행 형 패키지
- 10. 독립 실행 형 앱 개발
- 11. 독립 실행 형 capybara에서 출력물을 출력하는 방법
- 12. URL 매개 변수를 독립 실행 형 VBscript에 전달 하시겠습니까?
- 13. 디버그 모드에서 독립 실행 형 응용 프로그램으로 Windows 서비스 실행
- 14. Windows XP에서 Selenium Server 독립 실행 형 2를 서비스로 실행
- 15. 노드 응용 프로그램 용 독립 실행 형 GUI 모듈이 있습니까?
- 16. RKObjectMapping을 독립 실행 형 라이브러리로 사용하는 방법
- 17. 독립 실행 형 페이지에서 Server.Transfer하는 방법?
- 18. PyCharm에서 독립 실행 형 파일을 실행하는 방법
- 19. PostgreSQL - "독립 실행 형"코드를 실행하는 방법?
- 20. solr.analysis.WordDelimiterFilter 독립 실행 형 사용 방법
- 21. 독립 실행 형 파이썬 설치 방법
- 22. AndEngine - 독립 실행 형 쉐이더 사용 방법
- 23. 독립 실행 형 Java 기반 응용 프로그램 용 GUI 작성 용 패키지 (무료 또는 상용)
- 24. 컴파일 독립 실행 형 Windows는
- 25. Zend_filter_input 독립 실행 형 사용
- 26. 독립 실행 형 JdcbTemplate 사용
- 27. UI없이 독립 실행 형 Web.API
- 28. 독립 실행 형 기능이란 무엇입니까?
- 29. 독립 실행 형 Matlab 프로그램
- 30. 독립 실행 형 Qt 생성자
환상적입니다. 불행히도 패킷에서 RequestURL을 얻을 수없는 버그가 있지만이를 위해 내 자신의 메서드를 작성하기가 쉽습니다. 고마워요! –
나는 그것이 당신을 도왔다 니 기쁘다. 우리와 함께 해결 방법을 공유하면 다른 사람들을 도울 수 있습니다. –