本文整理汇总了Java中org.pcap4j.packet.IllegalRawDataException类的典型用法代码示例。如果您正苦于以下问题:Java IllegalRawDataException类的具体用法?Java IllegalRawDataException怎么用?Java IllegalRawDataException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IllegalRawDataException类属于org.pcap4j.packet包,在下文中一共展示了IllegalRawDataException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getIpV4Packet_pppoe
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
IpV4Packet getIpV4Packet_pppoe(EthernetPacket packet_eth) throws IllegalRawDataException{
IpV4Packet ipV4Packet=null;
byte[] pppData=packet_eth.getPayload().getRawData();
if(pppData.length>8&&pppData[8]==0x45){
byte[] b2=new byte[2];
System.arraycopy(pppData, 4, b2, 0, 2);
short len=(short) ByteShortConvert.toShort(b2, 0);
int ipLength=toUnsigned(len)-2;
byte[] ipData=new byte[ipLength];
//设置ppp参数
PacketUtils.pppHead_static[2]=pppData[2];
PacketUtils.pppHead_static[3]=pppData[3];
if(ipLength==(pppData.length-8)){
System.arraycopy(pppData, 8, ipData, 0, ipLength);
ipV4Packet=IpV4Packet.newPacket(ipData, 0, ipData.length);
}else {
MLog.println("长度不符!");
}
}
return ipV4Packet;
}
开发者ID:gmirr,项目名称:finalspeed-91yun,代码行数:22,代码来源:CapEnv.java
示例2: processUdpPacket
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
public static void processUdpPacket(Packet packet, PcapFileSummary pcapFileSummary, PacketInfo packetInfo, Mode mode) {
if (packet == null) {
return; // skip empty packets
}
String sourceAddress = packetInfo.get(PacketInfo.SOURCE_ADDRESS);
String destinationAddress = packetInfo.get(PacketInfo.DESTINATION_ADDRESS);
try {
log.trace("Converting to UDP packet");
UdpPacket udpPacket = UdpPacket.newPacket(packet.getRawData(), 0, packet.length());
UdpPacket.UdpHeader udpHeader = udpPacket.getHeader();
UdpPort sourcePort = udpHeader.getSrcPort();
UdpPort destinationPort = udpHeader.getDstPort();
packetInfo.put(PacketInfo.SOURCE_PORT, sourcePort.valueAsString());
packetInfo.put(PacketInfo.DESTINATION_PORT, destinationPort.valueAsString());
if (mode == Mode.POSSIBLE_ATTACKS_ANALYSIS) {
//pcapFileSummary.portScanDetector.add(packetInfo);
}
String udpSource = sourceAddress + ":" + sourcePort.toString();
String udpDestination = destinationAddress + ":" + destinationPort.toString();
log.trace("Adding UDP source to set: " + udpSource);
pcapFileSummary.udpSources.add(udpSource);
log.trace("UDP{ source: " + udpSource + ", destination: " + udpDestination + " }");
} catch (IllegalRawDataException e) {
log.error("Exception occurred while processing a packet. Exception was: " + e);
}
}
开发者ID:rmcnew,项目名称:LiquidFortressPacketAnalyzer,代码行数:27,代码来源:UdpPacketProcessor.java
示例3: processArpPacket
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
public static void processArpPacket(Packet packet, PcapFileSummary pcapFileSummary) {
if (packet == null) {
return; // skip empty packets
}
log.trace("Converting to ARP packet");
try {
ArpPacket arpPacket = ArpPacket.newPacket(packet.getRawData(), 0, packet.length());
ArpPacket.ArpHeader arpHeader = arpPacket.getHeader();
ArpOperation arpOperation = arpHeader.getOperation();
InetAddress sourceIp = arpHeader.getSrcProtocolAddr();
MacAddress sourceMac = arpHeader.getSrcHardwareAddr();
if (arpOperation == ArpOperation.REQUEST) {
// only add / check the source addresses for an ARP request
//IpMacTrackerResult result = pcapFileSummary.ipMacTracker.query(sourceIp.getHostAddress(), sourceMac.toString());
}
} catch (IllegalRawDataException e) {
log.error("Exception occurred while processing a packet. Exception was: " + e);
}
}
开发者ID:rmcnew,项目名称:LiquidFortressPacketAnalyzer,代码行数:22,代码来源:ArpPacketProcessor.java
示例4: getIpV4Packet_pppoe
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
IpV4Packet getIpV4Packet_pppoe(EthernetPacket packet_eth) throws IllegalRawDataException{
IpV4Packet ipV4Packet=null;
byte[] pppData=packet_eth.getPayload().getRawData();
if(pppData.length>8&&pppData[8]==0x45){
byte[] b2=new byte[2];
System.arraycopy(pppData, 4, b2, 0, 2);
short len=(short) ByteShortConvert.toShort(b2, 0);
int ipLength=toUnsigned(len)-2;
byte[] ipData=new byte[ipLength];
//设置ppp参数
PacketUtils.pppHead_static[2]=pppData[2];
PacketUtils.pppHead_static[3]=pppData[3];
if(ipLength==(pppData.length-8)){
System.arraycopy(pppData, 8, ipData, 0, ipLength);
ipV4Packet=IpV4Packet.newPacket(ipData, 0, ipData.length);
}else {
MLog.println("Length don't match!");
}
}
return ipV4Packet;
}
开发者ID:RCD-Y,项目名称:FinalSpeed-X,代码行数:22,代码来源:CapEnv.java
示例5: handleExportPcapFile
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
/**
* Export stream to pcap file
*/
public void handleExportPcapFile() {
try {
Profile p = tabledata.getProfiles().get(streamPacketTableView.getSelectionModel().getSelectedIndex());
String packetBinary = p.getStream().getPacket().getBinary();
byte[] pkt = Base64.decodeBase64(packetBinary);
Packet packet = EthernetPacket.newPacket(pkt, 0, pkt.length);
File pcapFile = File.createTempFile("temp-file-name", ".pcap");
PcapHandle handle = Pcaps.openDead(DataLinkType.EN10MB, 65536);
PcapDumper dumper = handle.dumpOpen(pcapFile.getAbsolutePath());
Timestamp ts = new Timestamp(0);
dumper.dump(packet, ts);
dumper.close();
handle.close();
String fileName = p.getName() + ".pcap";
Window owner = streamPacketTableView.getScene().getWindow();
FileManager.exportFile("Save Pcap File", fileName, pcapFile, owner, FileType.PCAP);
} catch (IllegalRawDataException | IOException | PcapNativeException | NotOpenException ex) {
LOG.error("Error during generate JSON file", ex);
}
}
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:26,代码来源:PacketTableView.java
示例6: getPacketInfo
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
/**
*
* @param packetBinary
* @return
*/
public PacketInfo getPacketInfo(String packetBinary) {
PacketInfo packetInfo = null;
try {
byte[] pkt = Base64.decodeBase64(packetBinary);
Packet packet = EthernetPacket.newPacket(pkt, 0, pkt.length);
packetInfo = getPacketTypeText(packet);
} catch (IllegalRawDataException ex) {
LOG.error("Error reading packet info", ex);
}
return packetInfo;
}
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:21,代码来源:TrafficProfile.java
示例7: buildIdealPkt
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
private static EthernetPacket buildIdealPkt(String pkt) {
byte[] pktBin = Base64.getDecoder().decode(pkt);
try {
return EthernetPacket.newPacket(pktBin, 0, pktBin.length);
} catch (IllegalRawDataException e) {
e.printStackTrace();
}
return null;
}
开发者ID:cisco-system-traffic-generator,项目名称:trex-java-sdk,代码行数:10,代码来源:TRexClientTest.java
示例8: processEthernetPacket
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
public static void processEthernetPacket(Packet packet, PcapFileSummary pcapFileSummary, PacketInfo packetInfo, Mode mode) {
if (packet == null) {
return; // skip empty packets
}
try {
log.trace("Converting to ethernet packet");
EthernetPacket ethernetPacket = EthernetPacket.newPacket(packet.getRawData(), 0, packet.length());
EthernetPacket.EthernetHeader ethernetHeader = ethernetPacket.getHeader();
MacAddress sourceMac = ethernetHeader.getSrcAddr();
log.trace("Source MAC: " + sourceMac);
packetInfo.put(PacketInfo.SOURCE_MAC, sourceMac.toString());
MacAddress destMac = ethernetHeader.getDstAddr();
log.trace("Destination MAC: " + destMac);
packetInfo.put(PacketInfo.DESTINATION_MAC, destMac.toString());
EtherType etherType = ethernetHeader.getType();
log.trace("EtherType: " + etherType.toString());
packetInfo.put(PacketInfo.ETHERTYPE, etherType.toString());
Packet payload = ethernetPacket.getPayload();
if (etherType == EtherType.IPV4) {
IpPacketProcessor.processIpv4Packet(payload, pcapFileSummary, packetInfo, mode);
} else if (etherType == EtherType.IPV6) {
IpPacketProcessor.processIpv6Packet(payload, pcapFileSummary, packetInfo, mode);
} else if ((mode == Mode.POSSIBLE_ATTACKS_ANALYSIS) && (etherType == EtherType.ARP)) {
pcapFileSummary.nonIpPacketCount++;
ArpPacketProcessor.processArpPacket(payload, pcapFileSummary);
} else {
pcapFileSummary.nonIpPacketCount++;
log.trace("Skipping packet with EtherType: " + etherType);
}
} catch (IllegalRawDataException e) {
log.error("Exception occurred while processing a packet. Exception was: " + e);
}
}
开发者ID:rmcnew,项目名称:LiquidFortressPacketAnalyzer,代码行数:34,代码来源:PcapFileProcessor.java
示例9: processIpv6Packet
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
public static void processIpv6Packet(Packet packet, PcapFileSummary pcapFileSummary, PacketInfo packetInfo, Mode mode) {
if (packet == null) {
return; // skip empty packets
}
try {
log.trace("Converting to IPv6 packet");
IpV6Packet ipV6Packet = IpV6Packet.newPacket(packet.getRawData(), 0, packet.length());
IpV6Packet.IpV6Header ipV6Header = ipV6Packet.getHeader();
Inet6Address sourceAddress = ipV6Header.getSrcAddr();
Inet6Address destAddress = ipV6Header.getDstAddr();
if (mode == Mode.POSSIBLE_ATTACKS_ANALYSIS) {
//pcapFileSummary.ipMacTracker.query(sourceAddress.getHostAddress(), sourceMac.toString());
}
packetInfo.put(PacketInfo.SOURCE_ADDRESS, sourceAddress.getHostAddress());
packetInfo.put(PacketInfo.DESTINATION_ADDRESS, destAddress.getHostAddress());
log.trace("Adding IPv6 addresses to set: source: " + sourceAddress.getHostAddress() + ", dest: " + destAddress.getHostAddress());
pcapFileSummary.uniqueIpAddresses.add(sourceAddress.getHostAddress());
pcapFileSummary.uniqueIpAddresses.add(destAddress.getHostAddress());
IpNumber ipNumber = ipV6Header.getProtocol();
packetInfo.put(PacketInfo.IP_PROTOCOL, ipNumber.toString());
pcapFileSummary.ipProtocolCounter.increment(ipNumber);
Packet payload = ipV6Packet.getPayload();
if (ipNumber == IpNumber.ICMPV4) {
IcmpPacketProcessor.processIcmpv4Packet(payload, pcapFileSummary, packetInfo, mode);
} else if (ipNumber == IpNumber.ICMPV6) {
IcmpPacketProcessor.processIcmpv6Packet(payload, pcapFileSummary, packetInfo, mode);
} else if (ipNumber == IpNumber.TCP) {
TcpPacketProcessor.processTcpPacket(payload, pcapFileSummary, packetInfo, mode);
} else if (ipNumber == IpNumber.UDP) {
UdpPacketProcessor.processUdpPacket(payload, pcapFileSummary, packetInfo, mode);
} else {
log.trace("Skipping packet: " + payload);
}
} catch (IllegalRawDataException e) {
log.error("Exception occurred while processing a packet. Exception was: " + e);
}
}
开发者ID:rmcnew,项目名称:LiquidFortressPacketAnalyzer,代码行数:38,代码来源:IpPacketProcessor.java
示例10: fixPacketLength
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
private void fixPacketLength() {
try {
EthernetPacket newPacket = packet;
if (packet.getRawData().length < getLength()) {
byte[] pad = new byte[getLength() - packet.getRawData().length];
newPacket = EthernetPacket.newPacket(ArrayUtils.addAll(packet.getRawData(), pad), 0, getLength());
} else {
newPacket = EthernetPacket.newPacket(packet.getRawData(), 0, getLength());
}
setPacket((EthernetPacket) newPacket);
} catch (IllegalRawDataException ex) {
Logger.getLogger(TrexEthernetPacket.class.getName()).log(Level.SEVERE, null, ex);
}
}
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:16,代码来源:TrexEthernetPacket.java
示例11: handleMouseClickedEvent
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
/**
* Handle mouse clicked event
*/
private void handleMouseClickedEvent() {
TreeTableRow<HexData> selectedRow = (TreeTableRow<HexData>) textField.getParent().getParent();
if (!selectedRow.getTreeItem().getValue().getOffset().contains("-")) {
String originalLine = textField.getText();
String selectedHex = textField.getSelectedText().trim();
String replacedHex = showDialog(selectedHex);
if (replacedHex != null) {
try {
textField.replaceSelection(replacedHex.toUpperCase());
String payLoad = hexToASCII(textField.getText());
TreeTableRow<HexData> hexTable = (TreeTableRow<HexData>) textField.getParent().getParent();
TreeItem<HexData> selectedItem = hexTable.getTreeItem();
selectedItem.setValue(new HexData(selectedItem.getValue().getOffset(), textField.getText(), packetParser.formatPayLoad(payLoad)));
String originalHex = getPacketHexFromList();
if (selectedItem.getValue().getOffset().contains("-")) {
originalHex = originalHex.replaceAll(originalLine.replaceAll(" ", "").replaceAll("\n", ""), textField.getText().replaceAll(" ", "").replaceAll("\n", ""));
}
byte[] rawdata = DatatypeConverter.parseHexBinary(originalHex);
EthernetPacket p = EthernetPacket.newPacket(rawdata, 0, rawdata.length);
packetParser.parsePacket(p, packetInfo);
treeRoot.getChildren().clear();
setData(packetInfo);
} catch (IllegalRawDataException ex) {
java.util.logging.Logger.getLogger(PacketHex.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:32,代码来源:PacketHex.java
示例12: testEthernetPacketWithoutVlan
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
/**
* Test of buildPacket method, of class TrexEthernetPacket.
*/
@Test
@Parameters({"macSrcAddress", "macDstAddress", "packetLength", "expectedHex"})
public void testEthernetPacketWithoutVlan(String macSrcAddress, String macDstAddress, int packetLength, String expectedHex) throws IOException, IllegalRawDataException {
LOG.info("------------Testing Ethernet packet");
// build ethernet packet
LOG.info("Building Ethernet packet");
AbstractPacket.AbstractBuilder builder = null;
TrexEthernetPacket instance = new TrexEthernetPacket();
instance.setSrcAddr(macSrcAddress);
instance.setDstAddr(macDstAddress);
instance.setLength(packetLength);
instance.buildPacket(builder);
LOG.info("Encoding packet data");
// Encode packet data
String encodedBinaryPacket = packetUtil.getEncodedPacket(instance.getPacket().getRawData());
LOG.info("Decoding packets and returning packet data information");
// Decode and return packet info
PacketInfo packetInfo = packetUtil.getPacketInfoData(encodedBinaryPacket);
LOG.info("Verifying packet data");
// Assert mac src/destination address
Assert.assertEquals(macSrcAddress, packetInfo.getSrcMac(), "Invalid MAC source address. ");
Assert.assertEquals(macDstAddress, packetInfo.getDestMac(), "Invalid MAC destination address. ");
// Verify packet length
Packet packet = packetUtil.getPacketFromEncodedString(encodedBinaryPacket);
Assert.assertEquals(packetLength, packetUtil.getPacketLength(packet), "Invalid Packet length. ");
// Verify packet data
String packetHex = DatatypeConverter.printHexBinary(packet.getRawData());
Assert.assertEquals(expectedHex.toLowerCase(), packetHex.toLowerCase(), "Invalid Packet hex. ");
}
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:42,代码来源:TrexEthernetPacketTest.java
示例13: handle
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
@Override
public void handle(byte[] payload, byte[] header, Dot11MetaInformation meta) throws IllegalRawDataException {
tick();
Dot11ManagementFrame disassociationRequest = Dot11ManagementFrame.newPacket(payload, 0, payload.length);
String destination = "";
if(disassociationRequest.getHeader().getAddress1() != null) {
destination = disassociationRequest.getHeader().getAddress1().toString();
}
String transmitter = "";
if(disassociationRequest.getHeader().getAddress2() != null) {
transmitter = disassociationRequest.getHeader().getAddress2().toString();
}
// Reason.
short reasonCode = Dot11LeavingReason.extract(payload, header);
String reasonString = Dot11LeavingReason.lookup(reasonCode);
String message = transmitter + " is disassociating from " + destination + " (" + reasonString + ")";
nzyme.notify(
new Notification(message, meta.getChannel())
.addField(FieldNames.TRANSMITTER, transmitter)
.addField(FieldNames.DESTINATION, destination)
.addField(FieldNames.REASON_CODE, reasonCode)
.addField(FieldNames.REASON_STRING, reasonString)
.addField(FieldNames.SUBTYPE, "disassoc"),
meta
);
LOG.debug(message);
}
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:35,代码来源:DisassociationFrameHandler.java
示例14: newPacket
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
public static Dot11ManagementFrame newPacket(byte[] rawData, int offset, int length) throws IllegalRawDataException {
ByteArrays.validateBounds(rawData, offset, length);
Dot11ManagementFrame.Dot11ManagementFrameHeader h = new Dot11ManagementFrame.Dot11ManagementFrameHeader(rawData, offset, length);
return new Dot11ManagementFrame(rawData, offset, length, h);
}
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:6,代码来源:Dot11ManagementFrame.java
示例15: Dot11ManagementFrameHeader
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
private Dot11ManagementFrameHeader(byte[] rawData, int offset, int length) throws IllegalRawDataException {
super(rawData, offset, length);
}
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:4,代码来源:Dot11ManagementFrame.java
示例16: handle
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
@Override
public void handle(byte[] payload, byte[] header, Dot11MetaInformation meta) throws IllegalRawDataException {
tick();
Dot11ManagementFrame deauth = Dot11ManagementFrame.newPacket(payload, 0, payload.length);
String destination = "";
if (deauth.getHeader().getAddress1() != null) {
destination = deauth.getHeader().getAddress1().toString();
}
String transmitter = "";
if (deauth.getHeader().getAddress2() != null) {
transmitter = deauth.getHeader().getAddress2().toString();
}
String bssid = "";
if (deauth.getHeader().getAddress3() != null) {
bssid = deauth.getHeader().getAddress3().toString();
}
// Reason.
short reasonCode = Dot11LeavingReason.extract(payload, header);
String reasonString = Dot11LeavingReason.lookup(reasonCode);
String message = "Deauth: Transmitter " + transmitter + " is deauthenticating " + destination
+ " from BSSID " + bssid + " (" + reasonString + ")";
nzyme.notify(
new Notification(message, meta.getChannel())
.addField(FieldNames.TRANSMITTER, transmitter)
.addField(FieldNames.DESTINATION, destination)
.addField(FieldNames.BSSID, bssid)
.addField(FieldNames.REASON_CODE, reasonCode)
.addField(FieldNames.REASON_STRING, reasonString)
.addField(FieldNames.SUBTYPE, "deauth"),
meta
);
LOG.debug(message);
}
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:42,代码来源:DeauthenticationFrameHandler.java
示例17: handle
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
@Override
public void handle(byte[] payload, byte[] header, Dot11MetaInformation meta) throws IllegalRawDataException {
tick();
if(nzyme.getConfiguration().getBeaconSamplingRate() != 0) { // skip this completely if sampling is disabled
if (sampleCount.getAndIncrement() == nzyme.getConfiguration().getBeaconSamplingRate()) {
sampleCount.set(0);
} else {
return;
}
}
Dot11ManagementFrame beacon = Dot11ManagementFrame.newPacket(payload, 0, payload.length);
String ssid = null;
try {
ssid = Dot11SSID.extractSSID(SSID_LENGTH_POSITION, SSID_POSITION, payload);
} catch (MalformedFrameException e) {
malformed(meta);
LOG.trace("Skipping malformed beacon frame.");
}
String transmitter = "";
if(beacon.getHeader().getAddress2() != null) {
transmitter = beacon.getHeader().getAddress2().toString();
}
String message;
if (ssid != null && !ssid.trim().isEmpty()) {
message = "Received beacon from " + transmitter + " for SSID " + ssid;
nzyme.getStatistics().tickBeaconedNetwork(ssid);
} else {
// Broadcast beacon.
message = "Received broadcast beacon from " + transmitter;
}
nzyme.getStatistics().tickAccessPoint(transmitter);
nzyme.notify(
new Notification(message, meta.getChannel())
.addField(FieldNames.TRANSMITTER, transmitter)
.addField(FieldNames.SSID, ssid == null ? "[no SSID]" : ssid)
.addField(FieldNames.SUBTYPE, "beacon"),
meta
);
LOG.debug(message);
}
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:48,代码来源:BeaconFrameHandler.java
示例18: handle
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
@Override
public void handle(byte[] payload, byte[] header, Dot11MetaInformation meta) throws IllegalRawDataException {
tick();
Dot11ProbeRequestPacket probeRequest = Dot11ProbeRequestPacket.newPacket(payload, 0, payload.length);
if (probeRequest.getHeader() == null) {
malformed(meta);
LOG.trace("Malformed header in probe request packet. Skipping.");
return;
}
String ssid;
boolean nullProbe = false;
if (probeRequest.getHeader().getSsid() != null) {
// Check if the SSID is valid UTF-8 (might me malformed frame)
if(!Tools.isValidUTF8(probeRequest.getHeader().getSsid().getRawData())) {
malformed(meta);
LOG.trace("Malformed SSID in probe request packet. Skipping.");
return;
}
ssid = Normalizer.normalize(probeRequest.getHeader().getSsid().getSsid(), Normalizer.Form.NFD);
if (ssid.trim().isEmpty()) {
ssid = "NULL";
nullProbe = true;
}
} else {
malformed(meta);
LOG.trace("Malformed SSID in probe request packet. Skipping.");
return;
}
String requester;
if (probeRequest.getHeader().getAddress2() != null) {
requester = Normalizer.normalize(probeRequest.getHeader().getAddress2().toString(), Normalizer.Form.NFD);
} else {
malformed(meta);
LOG.trace("Malformed SSID in probe request packet. Skipping.");
return;
}
String message;
if(!nullProbe) {
message = "Probe request: " + requester + " is looking for " + ssid;
} else {
message = "Probe request: " + requester + " is looking for any network. (null probe request)";
}
nzyme.getStatistics().tickProbingDevice(requester);
nzyme.notify(
new Notification(message, meta.getChannel())
.addField(FieldNames.SSID, ssid)
.addField(FieldNames.TRANSMITTER, requester)
.addField(FieldNames.SUBTYPE, "probe-req"),
meta
);
LOG.debug(message);
}
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:63,代码来源:ProbeRequestFrameHandler.java
示例19: handle
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
@Override
public void handle(byte[] payload, byte[] header, Dot11MetaInformation meta) throws IllegalRawDataException {
tick();
Dot11ManagementFrame probeReponse = Dot11ManagementFrame.newPacket(payload, 0, payload.length);
String ssid = null;
try {
ssid = Dot11SSID.extractSSID(SSID_LENGTH_POSITION, SSID_POSITION, payload);
} catch (MalformedFrameException e) {
malformed(meta);
LOG.trace("Skipping malformed probe-resp frame.");
}
if (ssid == null) {
ssid = "[no SSID]";
}
String destination = "";
if (probeReponse.getHeader().getAddress1() != null) {
destination = probeReponse.getHeader().getAddress1().toString();
}
String transmitter = "";
if (probeReponse.getHeader().getAddress2() != null) {
transmitter = probeReponse.getHeader().getAddress2().toString();
}
String message = transmitter + " responded to probe request from " + destination + " for " + ssid;
nzyme.notify(
new Notification(message, meta.getChannel())
.addField(FieldNames.DESTINATION, destination)
.addField(FieldNames.TRANSMITTER, transmitter)
.addField(FieldNames.SSID, ssid)
.addField(FieldNames.SUBTYPE, "probe-resp"),
meta
);
LOG.debug(message);
}
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:42,代码来源:ProbeResponseFrameHandler.java
示例20: handle
import org.pcap4j.packet.IllegalRawDataException; //导入依赖的package包/类
@Override
public void handle(byte[] payload, byte[] header, Dot11MetaInformation meta) throws IllegalRawDataException {
tick();
Dot11ManagementFrame associationRequest = Dot11ManagementFrame.newPacket(payload, 0, payload.length);
String destination = "";
if(associationRequest.getHeader().getAddress1() != null) {
destination = associationRequest.getHeader().getAddress1().toString();
}
String transmitter = "";
if(associationRequest.getHeader().getAddress2() != null) {
transmitter = associationRequest.getHeader().getAddress2().toString();
}
String ssid = null;
try {
ssid = Dot11SSID.extractSSID(SSID_LENGTH_POSITION, SSID_POSITION, payload);
} catch (MalformedFrameException e) {
malformed(meta);
LOG.trace("Skipping malformed assoc-req frame.");
}
if (ssid == null) {
ssid = "[no SSID]";
}
String message = transmitter + " is requesting to associate with " + ssid + " at " + destination;
nzyme.notify(
new Notification(message, meta.getChannel())
.addField(FieldNames.TRANSMITTER, transmitter)
.addField(FieldNames.DESTINATION, destination)
.addField(FieldNames.SSID, ssid)
.addField(FieldNames.SUBTYPE, "assoc-req"),
meta
);
LOG.debug(message);
}
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:42,代码来源:AssociationRequestFrameHandler.java
注:本文中的org.pcap4j.packet.IllegalRawDataException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论