repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
phaethon/kamene
kamene/contrib/gsm_um.py
authenticationAndCipheringRequest
def authenticationAndCipheringRequest( AuthenticationParameterRAND_presence=0, CiphKeySeqNr_presence=0): """AUTHENTICATION AND CIPHERING REQUEST Section 9.4.9""" a = TpPd(pd=0x3) b = MessageType(mesType=0x12) # 00010010 d = Cip...
python
def authenticationAndCipheringRequest( AuthenticationParameterRAND_presence=0, CiphKeySeqNr_presence=0): """AUTHENTICATION AND CIPHERING REQUEST Section 9.4.9""" a = TpPd(pd=0x3) b = MessageType(mesType=0x12) # 00010010 d = Cip...
[ "def", "authenticationAndCipheringRequest", "(", "AuthenticationParameterRAND_presence", "=", "0", ",", "CiphKeySeqNr_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x3", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x12", ")", "# 000...
AUTHENTICATION AND CIPHERING REQUEST Section 9.4.9
[ "AUTHENTICATION", "AND", "CIPHERING", "REQUEST", "Section", "9", ".", "4", ".", "9" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2450-L2465
phaethon/kamene
kamene/contrib/gsm_um.py
authenticationAndCipheringResponse
def authenticationAndCipheringResponse( AuthenticationParameterSRES_presence=0, MobileId_presence=0): """AUTHENTICATION AND CIPHERING RESPONSE Section 9.4.10""" a = TpPd(pd=0x3) b = MessageType(mesType=0x13) # 00010011 c = Ac...
python
def authenticationAndCipheringResponse( AuthenticationParameterSRES_presence=0, MobileId_presence=0): """AUTHENTICATION AND CIPHERING RESPONSE Section 9.4.10""" a = TpPd(pd=0x3) b = MessageType(mesType=0x13) # 00010011 c = Ac...
[ "def", "authenticationAndCipheringResponse", "(", "AuthenticationParameterSRES_presence", "=", "0", ",", "MobileId_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x3", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x13", ")", "# 000100...
AUTHENTICATION AND CIPHERING RESPONSE Section 9.4.10
[ "AUTHENTICATION", "AND", "CIPHERING", "RESPONSE", "Section", "9", ".", "4", ".", "10" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2468-L2482
phaethon/kamene
kamene/contrib/gsm_um.py
authenticationAndCipheringReject
def authenticationAndCipheringReject(): """AUTHENTICATION AND CIPHERING REJECT Section 9.4.11""" a = TpPd(pd=0x3) b = MessageType(mesType=0x14) # 00010100 packet = a / b return packet
python
def authenticationAndCipheringReject(): """AUTHENTICATION AND CIPHERING REJECT Section 9.4.11""" a = TpPd(pd=0x3) b = MessageType(mesType=0x14) # 00010100 packet = a / b return packet
[ "def", "authenticationAndCipheringReject", "(", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x3", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x14", ")", "# 00010100", "packet", "=", "a", "/", "b", "return", "packet" ]
AUTHENTICATION AND CIPHERING REJECT Section 9.4.11
[ "AUTHENTICATION", "AND", "CIPHERING", "REJECT", "Section", "9", ".", "4", ".", "11" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2485-L2490
phaethon/kamene
kamene/contrib/gsm_um.py
routingAreaUpdateRequest
def routingAreaUpdateRequest(PTmsiSignature_presence=0, GprsTimer_presence=0, DrxParameter_presence=0, TmsiStatus_presence=0): """ROUTING AREA UPDATE REQUEST Section 9.4.14""" a = TpPd(pd=0x3) b = MessageType(mesType=0x8)...
python
def routingAreaUpdateRequest(PTmsiSignature_presence=0, GprsTimer_presence=0, DrxParameter_presence=0, TmsiStatus_presence=0): """ROUTING AREA UPDATE REQUEST Section 9.4.14""" a = TpPd(pd=0x3) b = MessageType(mesType=0x8)...
[ "def", "routingAreaUpdateRequest", "(", "PTmsiSignature_presence", "=", "0", ",", "GprsTimer_presence", "=", "0", ",", "DrxParameter_presence", "=", "0", ",", "TmsiStatus_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x3", ")", "b", "=", ...
ROUTING AREA UPDATE REQUEST Section 9.4.14
[ "ROUTING", "AREA", "UPDATE", "REQUEST", "Section", "9", ".", "4", ".", "14" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2511-L2534
phaethon/kamene
kamene/contrib/gsm_um.py
routingAreaUpdateAccept
def routingAreaUpdateAccept(PTmsiSignature_presence=0, MobileId_presence=0, MobileId_presence1=0, ReceiveNpduNumbersList_presence=0, GprsTimer_presence=0, GmmCause_presence=0): """ROUTING AREA UPDATE ACCEPT Section 9.4.15""" a =...
python
def routingAreaUpdateAccept(PTmsiSignature_presence=0, MobileId_presence=0, MobileId_presence1=0, ReceiveNpduNumbersList_presence=0, GprsTimer_presence=0, GmmCause_presence=0): """ROUTING AREA UPDATE ACCEPT Section 9.4.15""" a =...
[ "def", "routingAreaUpdateAccept", "(", "PTmsiSignature_presence", "=", "0", ",", "MobileId_presence", "=", "0", ",", "MobileId_presence1", "=", "0", ",", "ReceiveNpduNumbersList_presence", "=", "0", ",", "GprsTimer_presence", "=", "0", ",", "GmmCause_presence", "=", ...
ROUTING AREA UPDATE ACCEPT Section 9.4.15
[ "ROUTING", "AREA", "UPDATE", "ACCEPT", "Section", "9", ".", "4", ".", "15" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2537-L2566
phaethon/kamene
kamene/contrib/gsm_um.py
routingAreaUpdateComplete
def routingAreaUpdateComplete(ReceiveNpduNumbersList_presence=0): """ROUTING AREA UPDATE COMPLETE Section 9.4.16""" a = TpPd(pd=0x3) b = MessageType(mesType=0xa) # 00001010 packet = a / b if ReceiveNpduNumbersList_presence is 1: c = ReceiveNpduNumbersList(ieiRNNL=0x26) packet = pack...
python
def routingAreaUpdateComplete(ReceiveNpduNumbersList_presence=0): """ROUTING AREA UPDATE COMPLETE Section 9.4.16""" a = TpPd(pd=0x3) b = MessageType(mesType=0xa) # 00001010 packet = a / b if ReceiveNpduNumbersList_presence is 1: c = ReceiveNpduNumbersList(ieiRNNL=0x26) packet = pack...
[ "def", "routingAreaUpdateComplete", "(", "ReceiveNpduNumbersList_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x3", ")", "b", "=", "MessageType", "(", "mesType", "=", "0xa", ")", "# 00001010", "packet", "=", "a", "/", "b", "if", "Rec...
ROUTING AREA UPDATE COMPLETE Section 9.4.16
[ "ROUTING", "AREA", "UPDATE", "COMPLETE", "Section", "9", ".", "4", ".", "16" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2569-L2577
phaethon/kamene
kamene/contrib/gsm_um.py
routingAreaUpdateReject
def routingAreaUpdateReject(): """ROUTING AREA UPDATE REJECT Section 9.4.17""" a = TpPd(pd=0x3) b = MessageType(mesType=0xb) # 00001011 c = GmmCause() d = ForceToStandbyAndSpareHalfOctets() packet = a / b / c / d return packet
python
def routingAreaUpdateReject(): """ROUTING AREA UPDATE REJECT Section 9.4.17""" a = TpPd(pd=0x3) b = MessageType(mesType=0xb) # 00001011 c = GmmCause() d = ForceToStandbyAndSpareHalfOctets() packet = a / b / c / d return packet
[ "def", "routingAreaUpdateReject", "(", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x3", ")", "b", "=", "MessageType", "(", "mesType", "=", "0xb", ")", "# 00001011", "c", "=", "GmmCause", "(", ")", "d", "=", "ForceToStandbyAndSpareHalfOctets", "(", ")",...
ROUTING AREA UPDATE REJECT Section 9.4.17
[ "ROUTING", "AREA", "UPDATE", "REJECT", "Section", "9", ".", "4", ".", "17" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2580-L2587
phaethon/kamene
kamene/contrib/gsm_um.py
gmmStatus
def gmmStatus(): """GMM STATUS Section 9.4.18""" a = TpPd(pd=0x3) b = MessageType(mesType=0x20) # 00100000 c = GmmCause() packet = a / b / c return packet
python
def gmmStatus(): """GMM STATUS Section 9.4.18""" a = TpPd(pd=0x3) b = MessageType(mesType=0x20) # 00100000 c = GmmCause() packet = a / b / c return packet
[ "def", "gmmStatus", "(", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x3", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x20", ")", "# 00100000", "c", "=", "GmmCause", "(", ")", "packet", "=", "a", "/", "b", "/", "c", "return", "packet" ]
GMM STATUS Section 9.4.18
[ "GMM", "STATUS", "Section", "9", ".", "4", ".", "18" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2590-L2596
phaethon/kamene
kamene/contrib/gsm_um.py
activatePdpContextRequest
def activatePdpContextRequest(AccessPointName_presence=0, ProtocolConfigurationOptions_presence=0): """ACTIVATE PDP CONTEXT REQUEST Section 9.5.1""" a = TpPd(pd=0x8) b = MessageType(mesType=0x41) # 01000001 c = NetworkServiceAccessPointIdentifier() d = LlcServiceAccess...
python
def activatePdpContextRequest(AccessPointName_presence=0, ProtocolConfigurationOptions_presence=0): """ACTIVATE PDP CONTEXT REQUEST Section 9.5.1""" a = TpPd(pd=0x8) b = MessageType(mesType=0x41) # 01000001 c = NetworkServiceAccessPointIdentifier() d = LlcServiceAccess...
[ "def", "activatePdpContextRequest", "(", "AccessPointName_presence", "=", "0", ",", "ProtocolConfigurationOptions_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x41", ")", "# 0100000...
ACTIVATE PDP CONTEXT REQUEST Section 9.5.1
[ "ACTIVATE", "PDP", "CONTEXT", "REQUEST", "Section", "9", ".", "5", ".", "1" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2628-L2644
phaethon/kamene
kamene/contrib/gsm_um.py
activatePdpContextAccept
def activatePdpContextAccept(PacketDataProtocolAddress_presence=0, ProtocolConfigurationOptions_presence=0): """ACTIVATE PDP CONTEXT ACCEPT Section 9.5.2""" a = TpPd(pd=0x8) b = MessageType(mesType=0x42) # 01000010 c = LlcServiceAccessPointIdentifier() d = QualityOfServ...
python
def activatePdpContextAccept(PacketDataProtocolAddress_presence=0, ProtocolConfigurationOptions_presence=0): """ACTIVATE PDP CONTEXT ACCEPT Section 9.5.2""" a = TpPd(pd=0x8) b = MessageType(mesType=0x42) # 01000010 c = LlcServiceAccessPointIdentifier() d = QualityOfServ...
[ "def", "activatePdpContextAccept", "(", "PacketDataProtocolAddress_presence", "=", "0", ",", "ProtocolConfigurationOptions_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x42", ")", "...
ACTIVATE PDP CONTEXT ACCEPT Section 9.5.2
[ "ACTIVATE", "PDP", "CONTEXT", "ACCEPT", "Section", "9", ".", "5", ".", "2" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2647-L2662
phaethon/kamene
kamene/contrib/gsm_um.py
requestPdpContextActivation
def requestPdpContextActivation(AccessPointName_presence=0): """REQUEST PDP CONTEXT ACTIVATION Section 9.5.4""" a = TpPd(pd=0x8) b = MessageType(mesType=0x44) # 01000100 c = PacketDataProtocolAddress() packet = a / b / c if AccessPointName_presence is 1: d = AccessPointName(ieiAPN=0x28)...
python
def requestPdpContextActivation(AccessPointName_presence=0): """REQUEST PDP CONTEXT ACTIVATION Section 9.5.4""" a = TpPd(pd=0x8) b = MessageType(mesType=0x44) # 01000100 c = PacketDataProtocolAddress() packet = a / b / c if AccessPointName_presence is 1: d = AccessPointName(ieiAPN=0x28)...
[ "def", "requestPdpContextActivation", "(", "AccessPointName_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x44", ")", "# 01000100", "c", "=", "PacketDataProtocolAddress", "(", ")",...
REQUEST PDP CONTEXT ACTIVATION Section 9.5.4
[ "REQUEST", "PDP", "CONTEXT", "ACTIVATION", "Section", "9", ".", "5", ".", "4" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2677-L2686
phaethon/kamene
kamene/contrib/gsm_um.py
requestPdpContextActivationReject
def requestPdpContextActivationReject(): """REQUEST PDP CONTEXT ACTIVATION REJECT Section 9.5.5""" a = TpPd(pd=0x8) b = MessageType(mesType=0x45) # 01000101 c = SmCause() packet = a / b / c return packet
python
def requestPdpContextActivationReject(): """REQUEST PDP CONTEXT ACTIVATION REJECT Section 9.5.5""" a = TpPd(pd=0x8) b = MessageType(mesType=0x45) # 01000101 c = SmCause() packet = a / b / c return packet
[ "def", "requestPdpContextActivationReject", "(", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x45", ")", "# 01000101", "c", "=", "SmCause", "(", ")", "packet", "=", "a", "/", "b", "/", "c", ...
REQUEST PDP CONTEXT ACTIVATION REJECT Section 9.5.5
[ "REQUEST", "PDP", "CONTEXT", "ACTIVATION", "REJECT", "Section", "9", ".", "5", ".", "5" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2689-L2695
phaethon/kamene
kamene/contrib/gsm_um.py
modifyPdpContextRequest
def modifyPdpContextRequest(): """MODIFY PDP CONTEXT REQUEST Section 9.5.6""" a = TpPd(pd=0x8) b = MessageType(mesType=0x48) # 01001000 c = RadioPriorityAndSpareHalfOctets() d = LlcServiceAccessPointIdentifier() e = QualityOfService() packet = a / b / c / d / e return packet
python
def modifyPdpContextRequest(): """MODIFY PDP CONTEXT REQUEST Section 9.5.6""" a = TpPd(pd=0x8) b = MessageType(mesType=0x48) # 01001000 c = RadioPriorityAndSpareHalfOctets() d = LlcServiceAccessPointIdentifier() e = QualityOfService() packet = a / b / c / d / e return packet
[ "def", "modifyPdpContextRequest", "(", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x48", ")", "# 01001000", "c", "=", "RadioPriorityAndSpareHalfOctets", "(", ")", "d", "=", "LlcServiceAccessPointIde...
MODIFY PDP CONTEXT REQUEST Section 9.5.6
[ "MODIFY", "PDP", "CONTEXT", "REQUEST", "Section", "9", ".", "5", ".", "6" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2698-L2706
phaethon/kamene
kamene/contrib/gsm_um.py
modifyPdpContextAccept
def modifyPdpContextAccept(): """MODIFY PDP CONTEXT ACCEPT Section 9.5.7""" a = TpPd(pd=0x8) b = MessageType(mesType=0x45) # 01000101 packet = a / b return packet
python
def modifyPdpContextAccept(): """MODIFY PDP CONTEXT ACCEPT Section 9.5.7""" a = TpPd(pd=0x8) b = MessageType(mesType=0x45) # 01000101 packet = a / b return packet
[ "def", "modifyPdpContextAccept", "(", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x45", ")", "# 01000101", "packet", "=", "a", "/", "b", "return", "packet" ]
MODIFY PDP CONTEXT ACCEPT Section 9.5.7
[ "MODIFY", "PDP", "CONTEXT", "ACCEPT", "Section", "9", ".", "5", ".", "7" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2709-L2714
phaethon/kamene
kamene/contrib/gsm_um.py
deactivatePdpContextAccept
def deactivatePdpContextAccept(): """DEACTIVATE PDP CONTEXT ACCEPT Section 9.5.9""" a = TpPd(pd=0x8) b = MessageType(mesType=0x47) # 01000111 packet = a / b return packet
python
def deactivatePdpContextAccept(): """DEACTIVATE PDP CONTEXT ACCEPT Section 9.5.9""" a = TpPd(pd=0x8) b = MessageType(mesType=0x47) # 01000111 packet = a / b return packet
[ "def", "deactivatePdpContextAccept", "(", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x47", ")", "# 01000111", "packet", "=", "a", "/", "b", "return", "packet" ]
DEACTIVATE PDP CONTEXT ACCEPT Section 9.5.9
[ "DEACTIVATE", "PDP", "CONTEXT", "ACCEPT", "Section", "9", ".", "5", ".", "9" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2726-L2731
phaethon/kamene
kamene/contrib/gsm_um.py
activateAaPdpContextRequest
def activateAaPdpContextRequest(AccessPointName_presence=0, ProtocolConfigurationOptions_presence=0, GprsTimer_presence=0): """ACTIVATE AA PDP CONTEXT REQUEST Section 9.5.10""" a = TpPd(pd=0x8) b = MessageType(mesType=0x50) # 01010000 c = ...
python
def activateAaPdpContextRequest(AccessPointName_presence=0, ProtocolConfigurationOptions_presence=0, GprsTimer_presence=0): """ACTIVATE AA PDP CONTEXT REQUEST Section 9.5.10""" a = TpPd(pd=0x8) b = MessageType(mesType=0x50) # 01010000 c = ...
[ "def", "activateAaPdpContextRequest", "(", "AccessPointName_presence", "=", "0", ",", "ProtocolConfigurationOptions_presence", "=", "0", ",", "GprsTimer_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", ...
ACTIVATE AA PDP CONTEXT REQUEST Section 9.5.10
[ "ACTIVATE", "AA", "PDP", "CONTEXT", "REQUEST", "Section", "9", ".", "5", ".", "10" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2734-L2754
phaethon/kamene
kamene/contrib/gsm_um.py
activateAaPdpContextAccept
def activateAaPdpContextAccept(ProtocolConfigurationOptions_presence=0, GprsTimer_presence=0): """ACTIVATE AA PDP CONTEXT ACCEPT Section 9.5.11""" a = TpPd(pd=0x8) b = MessageType(mesType=0x51) # 01010001 c = LlcServiceAccessPointIdentifier() d = QualityOfService() ...
python
def activateAaPdpContextAccept(ProtocolConfigurationOptions_presence=0, GprsTimer_presence=0): """ACTIVATE AA PDP CONTEXT ACCEPT Section 9.5.11""" a = TpPd(pd=0x8) b = MessageType(mesType=0x51) # 01010001 c = LlcServiceAccessPointIdentifier() d = QualityOfService() ...
[ "def", "activateAaPdpContextAccept", "(", "ProtocolConfigurationOptions_presence", "=", "0", ",", "GprsTimer_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x51", ")", "# 01010001", ...
ACTIVATE AA PDP CONTEXT ACCEPT Section 9.5.11
[ "ACTIVATE", "AA", "PDP", "CONTEXT", "ACCEPT", "Section", "9", ".", "5", ".", "11" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2757-L2774
phaethon/kamene
kamene/contrib/gsm_um.py
activateAaPdpContextReject
def activateAaPdpContextReject(ProtocolConfigurationOptions_presence=0): """ACTIVATE AA PDP CONTEXT REJECT Section 9.5.12""" a = TpPd(pd=0x8) b = MessageType(mesType=0x52) # 01010010 c = SmCause() packet = a / b / c if ProtocolConfigurationOptions_presence is 1: d = ProtocolConfiguratio...
python
def activateAaPdpContextReject(ProtocolConfigurationOptions_presence=0): """ACTIVATE AA PDP CONTEXT REJECT Section 9.5.12""" a = TpPd(pd=0x8) b = MessageType(mesType=0x52) # 01010010 c = SmCause() packet = a / b / c if ProtocolConfigurationOptions_presence is 1: d = ProtocolConfiguratio...
[ "def", "activateAaPdpContextReject", "(", "ProtocolConfigurationOptions_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x52", ")", "# 01010010", "c", "=", "SmCause", "(", ")", "pa...
ACTIVATE AA PDP CONTEXT REJECT Section 9.5.12
[ "ACTIVATE", "AA", "PDP", "CONTEXT", "REJECT", "Section", "9", ".", "5", ".", "12" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2777-L2786
phaethon/kamene
kamene/contrib/gsm_um.py
deactivateAaPdpContextRequest
def deactivateAaPdpContextRequest(): """DEACTIVATE AA PDP CONTEXT REQUEST Section 9.5.13""" a = TpPd(pd=0x8) b = MessageType(mesType=0x53) # 01010011 c = AaDeactivationCauseAndSpareHalfOctets() packet = a / b / c return packet
python
def deactivateAaPdpContextRequest(): """DEACTIVATE AA PDP CONTEXT REQUEST Section 9.5.13""" a = TpPd(pd=0x8) b = MessageType(mesType=0x53) # 01010011 c = AaDeactivationCauseAndSpareHalfOctets() packet = a / b / c return packet
[ "def", "deactivateAaPdpContextRequest", "(", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x53", ")", "# 01010011", "c", "=", "AaDeactivationCauseAndSpareHalfOctets", "(", ")", "packet", "=", "a", "...
DEACTIVATE AA PDP CONTEXT REQUEST Section 9.5.13
[ "DEACTIVATE", "AA", "PDP", "CONTEXT", "REQUEST", "Section", "9", ".", "5", ".", "13" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2789-L2795
phaethon/kamene
kamene/contrib/gsm_um.py
deactivateAaPdpContextAccept
def deactivateAaPdpContextAccept(): """DEACTIVATE AA PDP CONTEXT ACCEPT Section 9.5.14""" a = TpPd(pd=0x8) b = MessageType(mesType=0x54) # 01010100 packet = a / b return packet
python
def deactivateAaPdpContextAccept(): """DEACTIVATE AA PDP CONTEXT ACCEPT Section 9.5.14""" a = TpPd(pd=0x8) b = MessageType(mesType=0x54) # 01010100 packet = a / b return packet
[ "def", "deactivateAaPdpContextAccept", "(", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x8", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x54", ")", "# 01010100", "packet", "=", "a", "/", "b", "return", "packet" ]
DEACTIVATE AA PDP CONTEXT ACCEPT Section 9.5.14
[ "DEACTIVATE", "AA", "PDP", "CONTEXT", "ACCEPT", "Section", "9", ".", "5", ".", "14" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2798-L2803
phaethon/kamene
kamene/packet.py
ls
def ls(obj=None): """List available layers, or infos on a given layer""" if obj is None: import builtins all = builtins.__dict__.copy() all.update(globals()) objlst = sorted(conf.layers, key=lambda x:x.__name__) for o in objlst: print("%-10s : %s" %(...
python
def ls(obj=None): """List available layers, or infos on a given layer""" if obj is None: import builtins all = builtins.__dict__.copy() all.update(globals()) objlst = sorted(conf.layers, key=lambda x:x.__name__) for o in objlst: print("%-10s : %s" %(...
[ "def", "ls", "(", "obj", "=", "None", ")", ":", "if", "obj", "is", "None", ":", "import", "builtins", "all", "=", "builtins", ".", "__dict__", ".", "copy", "(", ")", "all", ".", "update", "(", "globals", "(", ")", ")", "objlst", "=", "sorted", "(...
List available layers, or infos on a given layer
[ "List", "available", "layers", "or", "infos", "on", "a", "given", "layer" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L1250-L1273
phaethon/kamene
kamene/packet.py
fuzz
def fuzz(p, _inplace=0): """Transform a layer into a fuzzy layer by replacing some default values by random objects""" if not _inplace: p = p.copy() q = p while not isinstance(q, NoPayload): for f in q.fields_desc: if isinstance(f, PacketListField): for r in g...
python
def fuzz(p, _inplace=0): """Transform a layer into a fuzzy layer by replacing some default values by random objects""" if not _inplace: p = p.copy() q = p while not isinstance(q, NoPayload): for f in q.fields_desc: if isinstance(f, PacketListField): for r in g...
[ "def", "fuzz", "(", "p", ",", "_inplace", "=", "0", ")", ":", "if", "not", "_inplace", ":", "p", "=", "p", ".", "copy", "(", ")", "q", "=", "p", "while", "not", "isinstance", "(", "q", ",", "NoPayload", ")", ":", "for", "f", "in", "q", ".", ...
Transform a layer into a fuzzy layer by replacing some default values by random objects
[ "Transform", "a", "layer", "into", "a", "fuzzy", "layer", "by", "replacing", "some", "default", "values", "by", "random", "objects" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L1282-L1301
phaethon/kamene
kamene/packet.py
Packet.copy
def copy(self): """Returns a deep copy of the instance.""" clone = self.__class__() clone.fields = self.fields.copy() for k in clone.fields: clone.fields[k] = self.get_field(k).do_copy(clone.fields[k]) clone.default_fields = self.default_fields.copy() clone.ov...
python
def copy(self): """Returns a deep copy of the instance.""" clone = self.__class__() clone.fields = self.fields.copy() for k in clone.fields: clone.fields[k] = self.get_field(k).do_copy(clone.fields[k]) clone.default_fields = self.default_fields.copy() clone.ov...
[ "def", "copy", "(", "self", ")", ":", "clone", "=", "self", ".", "__class__", "(", ")", "clone", ".", "fields", "=", "self", ".", "fields", ".", "copy", "(", ")", "for", "k", "in", "clone", ".", "fields", ":", "clone", ".", "fields", "[", "k", ...
Returns a deep copy of the instance.
[ "Returns", "a", "deep", "copy", "of", "the", "instance", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L148-L165
phaethon/kamene
kamene/packet.py
Packet.psdump
def psdump(self, filename=None, **kargs): """psdump(filename=None, layer_shift=0, rebuild=1) Creates an EPS file describing a packet. If filename is not provided a temporary file is created and gs is called.""" canvas = self.canvas_dump(**kargs) if filename is None: fname = get_temp_...
python
def psdump(self, filename=None, **kargs): """psdump(filename=None, layer_shift=0, rebuild=1) Creates an EPS file describing a packet. If filename is not provided a temporary file is created and gs is called.""" canvas = self.canvas_dump(**kargs) if filename is None: fname = get_temp_...
[ "def", "psdump", "(", "self", ",", "filename", "=", "None", ",", "*", "*", "kargs", ")", ":", "canvas", "=", "self", ".", "canvas_dump", "(", "*", "*", "kargs", ")", "if", "filename", "is", "None", ":", "fname", "=", "get_temp_file", "(", "autoext", ...
psdump(filename=None, layer_shift=0, rebuild=1) Creates an EPS file describing a packet. If filename is not provided a temporary file is created and gs is called.
[ "psdump", "(", "filename", "=", "None", "layer_shift", "=", "0", "rebuild", "=", "1", ")", "Creates", "an", "EPS", "file", "describing", "a", "packet", ".", "If", "filename", "is", "not", "provided", "a", "temporary", "file", "is", "created", "and", "gs"...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L404-L413
phaethon/kamene
kamene/packet.py
Packet.pdfdump
def pdfdump(self, filename=None, **kargs): """pdfdump(filename=None, layer_shift=0, rebuild=1) Creates a PDF file describing a packet. If filename is not provided a temporary file is created and xpdf is called.""" canvas = self.canvas_dump(**kargs) if filename is None: fname ...
python
def pdfdump(self, filename=None, **kargs): """pdfdump(filename=None, layer_shift=0, rebuild=1) Creates a PDF file describing a packet. If filename is not provided a temporary file is created and xpdf is called.""" canvas = self.canvas_dump(**kargs) if filename is None: fname ...
[ "def", "pdfdump", "(", "self", ",", "filename", "=", "None", ",", "*", "*", "kargs", ")", ":", "canvas", "=", "self", ".", "canvas_dump", "(", "*", "*", "kargs", ")", "if", "filename", "is", "None", ":", "fname", "=", "get_temp_file", "(", "autoext",...
pdfdump(filename=None, layer_shift=0, rebuild=1) Creates a PDF file describing a packet. If filename is not provided a temporary file is created and xpdf is called.
[ "pdfdump", "(", "filename", "=", "None", "layer_shift", "=", "0", "rebuild", "=", "1", ")", "Creates", "a", "PDF", "file", "describing", "a", "packet", ".", "If", "filename", "is", "not", "provided", "a", "temporary", "file", "is", "created", "and", "xpd...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L415-L424
phaethon/kamene
kamene/packet.py
Packet.guess_payload_class
def guess_payload_class(self, payload): """DEV: Guesses the next payload class from layer bonds. Can be overloaded to use a different mechanism.""" for t in self.aliastypes: for fval, cls in t.payload_guess: ok = 1 for k in fval.keys(): if ...
python
def guess_payload_class(self, payload): """DEV: Guesses the next payload class from layer bonds. Can be overloaded to use a different mechanism.""" for t in self.aliastypes: for fval, cls in t.payload_guess: ok = 1 for k in fval.keys(): if ...
[ "def", "guess_payload_class", "(", "self", ",", "payload", ")", ":", "for", "t", "in", "self", ".", "aliastypes", ":", "for", "fval", ",", "cls", "in", "t", ".", "payload_guess", ":", "ok", "=", "1", "for", "k", "in", "fval", ".", "keys", "(", ")",...
DEV: Guesses the next payload class from layer bonds. Can be overloaded to use a different mechanism.
[ "DEV", ":", "Guesses", "the", "next", "payload", "class", "from", "layer", "bonds", ".", "Can", "be", "overloaded", "to", "use", "a", "different", "mechanism", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L635-L646
phaethon/kamene
kamene/packet.py
Packet.hide_defaults
def hide_defaults(self): """Removes fields' values that are the same as default values.""" for k in list(self.fields.keys()): if k in self.default_fields: if self.default_fields[k] == self.fields[k]: del(self.fields[k]) self.payload.hide_defaults()
python
def hide_defaults(self): """Removes fields' values that are the same as default values.""" for k in list(self.fields.keys()): if k in self.default_fields: if self.default_fields[k] == self.fields[k]: del(self.fields[k]) self.payload.hide_defaults()
[ "def", "hide_defaults", "(", "self", ")", ":", "for", "k", "in", "list", "(", "self", ".", "fields", ".", "keys", "(", ")", ")", ":", "if", "k", "in", "self", ".", "default_fields", ":", "if", "self", ".", "default_fields", "[", "k", "]", "==", "...
Removes fields' values that are the same as default values.
[ "Removes", "fields", "values", "that", "are", "the", "same", "as", "default", "values", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L652-L658
phaethon/kamene
kamene/packet.py
Packet.haslayer
def haslayer(self, cls): """true if self has a layer that is an instance of cls. Superseded by "cls in self" syntax.""" if self.__class__ == cls or self.__class__.__name__ == cls: return 1 for f in self.packetfields: fvalue_gen = self.getfieldval(f.name) if fv...
python
def haslayer(self, cls): """true if self has a layer that is an instance of cls. Superseded by "cls in self" syntax.""" if self.__class__ == cls or self.__class__.__name__ == cls: return 1 for f in self.packetfields: fvalue_gen = self.getfieldval(f.name) if fv...
[ "def", "haslayer", "(", "self", ",", "cls", ")", ":", "if", "self", ".", "__class__", "==", "cls", "or", "self", ".", "__class__", ".", "__name__", "==", "cls", ":", "return", "1", "for", "f", "in", "self", ".", "packetfields", ":", "fvalue_gen", "="...
true if self has a layer that is an instance of cls. Superseded by "cls in self" syntax.
[ "true", "if", "self", "has", "a", "layer", "that", "is", "an", "instance", "of", "cls", ".", "Superseded", "by", "cls", "in", "self", "syntax", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L749-L764
phaethon/kamene
kamene/packet.py
Packet.getlayer
def getlayer(self, cls, nb=1, _track=None): """Return the nb^th layer that is an instance of cls.""" if type(cls) is int: nb = cls+1 cls = None if type(cls) is str and "." in cls: ccls,fld = cls.split(".",1) else: ccls,fld = cls,None ...
python
def getlayer(self, cls, nb=1, _track=None): """Return the nb^th layer that is an instance of cls.""" if type(cls) is int: nb = cls+1 cls = None if type(cls) is str and "." in cls: ccls,fld = cls.split(".",1) else: ccls,fld = cls,None ...
[ "def", "getlayer", "(", "self", ",", "cls", ",", "nb", "=", "1", ",", "_track", "=", "None", ")", ":", "if", "type", "(", "cls", ")", "is", "int", ":", "nb", "=", "cls", "+", "1", "cls", "=", "None", "if", "type", "(", "cls", ")", "is", "st...
Return the nb^th layer that is an instance of cls.
[ "Return", "the", "nb^th", "layer", "that", "is", "an", "instance", "of", "cls", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L765-L795
phaethon/kamene
kamene/packet.py
Packet.show
def show(self, indent=3, lvl="", label_lvl=""): """Prints a hierarchical view of the packet. "indent" gives the size of indentation for each layer.""" ct = conf.color_theme print("%s%s %s %s" % (label_lvl, ct.punct("###["), ct.layer_nam...
python
def show(self, indent=3, lvl="", label_lvl=""): """Prints a hierarchical view of the packet. "indent" gives the size of indentation for each layer.""" ct = conf.color_theme print("%s%s %s %s" % (label_lvl, ct.punct("###["), ct.layer_nam...
[ "def", "show", "(", "self", ",", "indent", "=", "3", ",", "lvl", "=", "\"\"", ",", "label_lvl", "=", "\"\"", ")", ":", "ct", "=", "conf", ".", "color_theme", "print", "(", "\"%s%s %s %s\"", "%", "(", "label_lvl", ",", "ct", ".", "punct", "(", "\"##...
Prints a hierarchical view of the packet. "indent" gives the size of indentation for each layer.
[ "Prints", "a", "hierarchical", "view", "of", "the", "packet", ".", "indent", "gives", "the", "size", "of", "indentation", "for", "each", "layer", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L843-L876
phaethon/kamene
kamene/packet.py
Packet.decode_payload_as
def decode_payload_as(self,cls): """Reassembles the payload and decode it using another packet class""" s = bytes(self.payload) self.payload = cls(s, _internal=1, _underlayer=self) pp = self while pp.underlayer is not None: pp = pp.underlayer self.payload.diss...
python
def decode_payload_as(self,cls): """Reassembles the payload and decode it using another packet class""" s = bytes(self.payload) self.payload = cls(s, _internal=1, _underlayer=self) pp = self while pp.underlayer is not None: pp = pp.underlayer self.payload.diss...
[ "def", "decode_payload_as", "(", "self", ",", "cls", ")", ":", "s", "=", "bytes", "(", "self", ".", "payload", ")", "self", ".", "payload", "=", "cls", "(", "s", ",", "_internal", "=", "1", ",", "_underlayer", "=", "self", ")", "pp", "=", "self", ...
Reassembles the payload and decode it using another packet class
[ "Reassembles", "the", "payload", "and", "decode", "it", "using", "another", "packet", "class" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L1026-L1033
phaethon/kamene
kamene/packet.py
Packet.libnet
def libnet(self): """Not ready yet. Should give the necessary C code that interfaces with libnet to recreate the packet""" print("libnet_build_%s(" % self.__class__.name.lower()) det = self.__class__(str(self)) for f in self.fields_desc: val = det.getfieldval(f.name) ...
python
def libnet(self): """Not ready yet. Should give the necessary C code that interfaces with libnet to recreate the packet""" print("libnet_build_%s(" % self.__class__.name.lower()) det = self.__class__(str(self)) for f in self.fields_desc: val = det.getfieldval(f.name) ...
[ "def", "libnet", "(", "self", ")", ":", "print", "(", "\"libnet_build_%s(\"", "%", "self", ".", "__class__", ".", "name", ".", "lower", "(", ")", ")", "det", "=", "self", ".", "__class__", "(", "str", "(", "self", ")", ")", "for", "f", "in", "self"...
Not ready yet. Should give the necessary C code that interfaces with libnet to recreate the packet
[ "Not", "ready", "yet", ".", "Should", "give", "the", "necessary", "C", "code", "that", "interfaces", "with", "libnet", "to", "recreate", "the", "packet" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L1035-L1048
phaethon/kamene
kamene/packet.py
Packet.command
def command(self): """Returns a string representing the command you have to type to obtain the same packet""" f = [] for fn,fv in self.fields.items(): fld = self.get_field(fn) if isinstance(fv, Packet): fv = fv.command() elif fld.islist and fld...
python
def command(self): """Returns a string representing the command you have to type to obtain the same packet""" f = [] for fn,fv in self.fields.items(): fld = self.get_field(fn) if isinstance(fv, Packet): fv = fv.command() elif fld.islist and fld...
[ "def", "command", "(", "self", ")", ":", "f", "=", "[", "]", "for", "fn", ",", "fv", "in", "self", ".", "fields", ".", "items", "(", ")", ":", "fld", "=", "self", ".", "get_field", "(", "fn", ")", "if", "isinstance", "(", "fv", ",", "Packet", ...
Returns a string representing the command you have to type to obtain the same packet
[ "Returns", "a", "string", "representing", "the", "command", "you", "have", "to", "type", "to", "obtain", "the", "same", "packet" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L1049-L1066
phaethon/kamene
kamene/contrib/doip.py
DoIPRawPacket.dissect
def dissect(self, b): """ Dissect an incoming DoIP packet. :param b: bytes to dissect :type b: bytes :raises: ValueError """ if len(b) < 8: raise ValueError("given packet too short") return super(DoIPRawPacket, self).dissect(b)
python
def dissect(self, b): """ Dissect an incoming DoIP packet. :param b: bytes to dissect :type b: bytes :raises: ValueError """ if len(b) < 8: raise ValueError("given packet too short") return super(DoIPRawPacket, self).dissect(b)
[ "def", "dissect", "(", "self", ",", "b", ")", ":", "if", "len", "(", "b", ")", "<", "8", ":", "raise", "ValueError", "(", "\"given packet too short\"", ")", "return", "super", "(", "DoIPRawPacket", ",", "self", ")", ".", "dissect", "(", "b", ")" ]
Dissect an incoming DoIP packet. :param b: bytes to dissect :type b: bytes :raises: ValueError
[ "Dissect", "an", "incoming", "DoIP", "packet", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/doip.py#L69-L79
phaethon/kamene
kamene/route6.py
Route6.make_route
def make_route(self, dst, gw=None, dev=None): """Internal function : create a route for 'dst' via 'gw'. """ prefix, plen = (dst.split("/")+["128"])[:2] plen = int(plen) if gw is None: gw = "::" if dev is None: dev, ifaddr, x = self.route(gw) ...
python
def make_route(self, dst, gw=None, dev=None): """Internal function : create a route for 'dst' via 'gw'. """ prefix, plen = (dst.split("/")+["128"])[:2] plen = int(plen) if gw is None: gw = "::" if dev is None: dev, ifaddr, x = self.route(gw) ...
[ "def", "make_route", "(", "self", ",", "dst", ",", "gw", "=", "None", ",", "dev", "=", "None", ")", ":", "prefix", ",", "plen", "=", "(", "dst", ".", "split", "(", "\"/\"", ")", "+", "[", "\"128\"", "]", ")", "[", ":", "2", "]", "plen", "=", ...
Internal function : create a route for 'dst' via 'gw'.
[ "Internal", "function", ":", "create", "a", "route", "for", "dst", "via", "gw", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/route6.py#L65-L83
phaethon/kamene
kamene/route6.py
Route6.delt
def delt(self, dst, gw=None): """ Ex: delt(dst="::/0") delt(dst="2001:db8:cafe:f000::/56") delt(dst="2001:db8:cafe:f000::/56", gw="2001:db8:deca::1") """ tmp = dst+b"/128" dst, plen = tmp.split(b'/')[:2] dst = in6_ptop(dst) plen = int(plen) ...
python
def delt(self, dst, gw=None): """ Ex: delt(dst="::/0") delt(dst="2001:db8:cafe:f000::/56") delt(dst="2001:db8:cafe:f000::/56", gw="2001:db8:deca::1") """ tmp = dst+b"/128" dst, plen = tmp.split(b'/')[:2] dst = in6_ptop(dst) plen = int(plen) ...
[ "def", "delt", "(", "self", ",", "dst", ",", "gw", "=", "None", ")", ":", "tmp", "=", "dst", "+", "b\"/128\"", "dst", ",", "plen", "=", "tmp", ".", "split", "(", "b'/'", ")", "[", ":", "2", "]", "dst", "=", "in6_ptop", "(", "dst", ")", "plen"...
Ex: delt(dst="::/0") delt(dst="2001:db8:cafe:f000::/56") delt(dst="2001:db8:cafe:f000::/56", gw="2001:db8:deca::1")
[ "Ex", ":", "delt", "(", "dst", "=", "::", "/", "0", ")", "delt", "(", "dst", "=", "2001", ":", "db8", ":", "cafe", ":", "f000", "::", "/", "56", ")", "delt", "(", "dst", "=", "2001", ":", "db8", ":", "cafe", ":", "f000", "::", "/", "56", ...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/route6.py#L96-L119
phaethon/kamene
kamene/route6.py
Route6.route
def route(self, dst, dev=None): """ Provide best route to IPv6 destination address, based on Scapy6 internal routing table content. When a set of address is passed (e.g. 2001:db8:cafe:*::1-5) an address of the set is used. Be aware of that behavior when using wildcards in ...
python
def route(self, dst, dev=None): """ Provide best route to IPv6 destination address, based on Scapy6 internal routing table content. When a set of address is passed (e.g. 2001:db8:cafe:*::1-5) an address of the set is used. Be aware of that behavior when using wildcards in ...
[ "def", "route", "(", "self", ",", "dst", ",", "dev", "=", "None", ")", ":", "# Transform \"2001:db8:cafe:*::1-5:0/120\" to one IPv6 address of the set", "dst", "=", "dst", ".", "split", "(", "\"/\"", ")", "[", "0", "]", "savedst", "=", "dst", "# In case followin...
Provide best route to IPv6 destination address, based on Scapy6 internal routing table content. When a set of address is passed (e.g. 2001:db8:cafe:*::1-5) an address of the set is used. Be aware of that behavior when using wildcards in upper parts of addresses ! If 'dst' para...
[ "Provide", "best", "route", "to", "IPv6", "destination", "address", "based", "on", "Scapy6", "internal", "routing", "table", "content", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/route6.py#L172-L276
phaethon/kamene
kamene/layers/l2.py
arping
def arping(net, timeout=2, cache=0, verbose=None, **kargs): """Send ARP who-has requests to determine which hosts are up arping(net, [cache=0,] [iface=conf.iface,] [verbose=conf.verb]) -> None Set cache=True if you want arping to modify internal ARP-Cache""" if verbose is None: verbose = conf.verb a...
python
def arping(net, timeout=2, cache=0, verbose=None, **kargs): """Send ARP who-has requests to determine which hosts are up arping(net, [cache=0,] [iface=conf.iface,] [verbose=conf.verb]) -> None Set cache=True if you want arping to modify internal ARP-Cache""" if verbose is None: verbose = conf.verb a...
[ "def", "arping", "(", "net", ",", "timeout", "=", "2", ",", "cache", "=", "0", ",", "verbose", "=", "None", ",", "*", "*", "kargs", ")", ":", "if", "verbose", "is", "None", ":", "verbose", "=", "conf", ".", "verb", "ans", ",", "unans", "=", "sr...
Send ARP who-has requests to determine which hosts are up arping(net, [cache=0,] [iface=conf.iface,] [verbose=conf.verb]) -> None Set cache=True if you want arping to modify internal ARP-Cache
[ "Send", "ARP", "who", "-", "has", "requests", "to", "determine", "which", "hosts", "are", "up", "arping", "(", "net", "[", "cache", "=", "0", "]", "[", "iface", "=", "conf", ".", "iface", "]", "[", "verbose", "=", "conf", ".", "verb", "]", ")", "...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/l2.py#L465-L480
phaethon/kamene
kamene/layers/l2.py
etherleak
def etherleak(target, **kargs): """Exploit Etherleak flaw""" return srpflood(Ether()/ARP(pdst=target), prn=lambda a: conf.padding_layer in a[1] and hexstr(a[1][conf.padding_layer].load), filter="arp", **kargs)
python
def etherleak(target, **kargs): """Exploit Etherleak flaw""" return srpflood(Ether()/ARP(pdst=target), prn=lambda a: conf.padding_layer in a[1] and hexstr(a[1][conf.padding_layer].load), filter="arp", **kargs)
[ "def", "etherleak", "(", "target", ",", "*", "*", "kargs", ")", ":", "return", "srpflood", "(", "Ether", "(", ")", "/", "ARP", "(", "pdst", "=", "target", ")", ",", "prn", "=", "lambda", "a", ":", "conf", ".", "padding_layer", "in", "a", "[", "1"...
Exploit Etherleak flaw
[ "Exploit", "Etherleak", "flaw" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/l2.py#L537-L541
phaethon/kamene
kamene/pton_ntop.py
inet_pton
def inet_pton(af, addr): """Convert an IP address from text representation into binary form""" print('hello') if af == socket.AF_INET: return inet_aton(addr) elif af == socket.AF_INET6: # IPv6: The use of "::" indicates one or more groups of 16 bits of zeros. # We deal with this ...
python
def inet_pton(af, addr): """Convert an IP address from text representation into binary form""" print('hello') if af == socket.AF_INET: return inet_aton(addr) elif af == socket.AF_INET6: # IPv6: The use of "::" indicates one or more groups of 16 bits of zeros. # We deal with this ...
[ "def", "inet_pton", "(", "af", ",", "addr", ")", ":", "print", "(", "'hello'", ")", "if", "af", "==", "socket", ".", "AF_INET", ":", "return", "inet_aton", "(", "addr", ")", "elif", "af", "==", "socket", ".", "AF_INET6", ":", "# IPv6: The use of \"::\" i...
Convert an IP address from text representation into binary form
[ "Convert", "an", "IP", "address", "from", "text", "representation", "into", "binary", "form" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/pton_ntop.py#L15-L61
phaethon/kamene
kamene/pton_ntop.py
inet_ntop
def inet_ntop(af, addr): """Convert an IP address from binary form into text represenation""" if af == socket.AF_INET: return inet_ntoa(addr) elif af == socket.AF_INET6: # IPv6 addresses have 128bits (16 bytes) if len(addr) != 16: raise Exception("Illegal syntax for IP ad...
python
def inet_ntop(af, addr): """Convert an IP address from binary form into text represenation""" if af == socket.AF_INET: return inet_ntoa(addr) elif af == socket.AF_INET6: # IPv6 addresses have 128bits (16 bytes) if len(addr) != 16: raise Exception("Illegal syntax for IP ad...
[ "def", "inet_ntop", "(", "af", ",", "addr", ")", ":", "if", "af", "==", "socket", ".", "AF_INET", ":", "return", "inet_ntoa", "(", "addr", ")", "elif", "af", "==", "socket", ".", "AF_INET6", ":", "# IPv6 addresses have 128bits (16 bytes)", "if", "len", "("...
Convert an IP address from binary form into text represenation
[ "Convert", "an", "IP", "address", "from", "binary", "form", "into", "text", "represenation" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/pton_ntop.py#L64-L90
phaethon/kamene
kamene/crypto/cert.py
zerofree_randstring
def zerofree_randstring(l): """ Returns a random string of length l (l >= 0) without zero in it. """ tmp = map(lambda x: struct.pack("B", random.randrange(1, 256, 1)), [""]*l) return "".join(tmp)
python
def zerofree_randstring(l): """ Returns a random string of length l (l >= 0) without zero in it. """ tmp = map(lambda x: struct.pack("B", random.randrange(1, 256, 1)), [""]*l) return "".join(tmp)
[ "def", "zerofree_randstring", "(", "l", ")", ":", "tmp", "=", "map", "(", "lambda", "x", ":", "struct", ".", "pack", "(", "\"B\"", ",", "random", ".", "randrange", "(", "1", ",", "256", ",", "1", ")", ")", ",", "[", "\"\"", "]", "*", "l", ")", ...
Returns a random string of length l (l >= 0) without zero in it.
[ "Returns", "a", "random", "string", "of", "length", "l", "(", "l", ">", "=", "0", ")", "without", "zero", "in", "it", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L50-L55
phaethon/kamene
kamene/crypto/cert.py
strand
def strand(s1, s2): """ Returns the binary AND of the 2 provided strings s1 and s2. s1 and s2 must be of same length. """ return "".join(map(lambda x,y:chr(ord(x)&ord(y)), s1, s2))
python
def strand(s1, s2): """ Returns the binary AND of the 2 provided strings s1 and s2. s1 and s2 must be of same length. """ return "".join(map(lambda x,y:chr(ord(x)&ord(y)), s1, s2))
[ "def", "strand", "(", "s1", ",", "s2", ")", ":", "return", "\"\"", ".", "join", "(", "map", "(", "lambda", "x", ",", "y", ":", "chr", "(", "ord", "(", "x", ")", "&", "ord", "(", "y", ")", ")", ",", "s1", ",", "s2", ")", ")" ]
Returns the binary AND of the 2 provided strings s1 and s2. s1 and s2 must be of same length.
[ "Returns", "the", "binary", "AND", "of", "the", "2", "provided", "strings", "s1", "and", "s2", ".", "s1", "and", "s2", "must", "be", "of", "same", "length", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L57-L62
phaethon/kamene
kamene/crypto/cert.py
pkcs_i2osp
def pkcs_i2osp(x,xLen): """ Converts a long (the first parameter) to the associated byte string representation of length l (second parameter). Basically, the length parameters allow the function to perform the associated padding. Input : x nonnegative integer to be converted xLen...
python
def pkcs_i2osp(x,xLen): """ Converts a long (the first parameter) to the associated byte string representation of length l (second parameter). Basically, the length parameters allow the function to perform the associated padding. Input : x nonnegative integer to be converted xLen...
[ "def", "pkcs_i2osp", "(", "x", ",", "xLen", ")", ":", "z", "=", "number", ".", "long_to_bytes", "(", "x", ")", "padlen", "=", "max", "(", "0", ",", "xLen", "-", "len", "(", "z", ")", ")", "return", "'\\x00'", "*", "padlen", "+", "z" ]
Converts a long (the first parameter) to the associated byte string representation of length l (second parameter). Basically, the length parameters allow the function to perform the associated padding. Input : x nonnegative integer to be converted xLen intended length of the resultin...
[ "Converts", "a", "long", "(", "the", "first", "parameter", ")", "to", "the", "associated", "byte", "string", "representation", "of", "length", "l", "(", "second", "parameter", ")", ".", "Basically", "the", "length", "parameters", "allow", "the", "function", ...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L79-L94
phaethon/kamene
kamene/crypto/cert.py
pkcs_mgf1
def pkcs_mgf1(mgfSeed, maskLen, h): """ Implements generic MGF1 Mask Generation function as described in Appendix B.2.1 of RFC 3447. The hash function is passed by name. valid values are 'md2', 'md4', 'md5', 'sha1', 'tls, 'sha256', 'sha384' and 'sha512'. Returns None on error. Input: mgf...
python
def pkcs_mgf1(mgfSeed, maskLen, h): """ Implements generic MGF1 Mask Generation function as described in Appendix B.2.1 of RFC 3447. The hash function is passed by name. valid values are 'md2', 'md4', 'md5', 'sha1', 'tls, 'sha256', 'sha384' and 'sha512'. Returns None on error. Input: mgf...
[ "def", "pkcs_mgf1", "(", "mgfSeed", ",", "maskLen", ",", "h", ")", ":", "# steps are those of Appendix B.2.1", "if", "not", "h", "in", "_hashFuncParams", ":", "warning", "(", "\"pkcs_mgf1: invalid hash (%s) provided\"", ")", "return", "None", "hLen", "=", "_hashFunc...
Implements generic MGF1 Mask Generation function as described in Appendix B.2.1 of RFC 3447. The hash function is passed by name. valid values are 'md2', 'md4', 'md5', 'sha1', 'tls, 'sha256', 'sha384' and 'sha512'. Returns None on error. Input: mgfSeed: seed from which mask is generated, an octe...
[ "Implements", "generic", "MGF1", "Mask", "Generation", "function", "as", "described", "in", "Appendix", "B", ".", "2", ".", "1", "of", "RFC", "3447", ".", "The", "hash", "function", "is", "passed", "by", "name", ".", "valid", "values", "are", "md2", "md4...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L160-L195
phaethon/kamene
kamene/crypto/cert.py
pkcs_emsa_pss_encode
def pkcs_emsa_pss_encode(M, emBits, h, mgf, sLen): """ Implements EMSA-PSS-ENCODE() function described in Sect. 9.1.1 of RFC 3447 Input: M : message to be encoded, an octet string emBits: maximal bit length of the integer resulting of pkcs_os2ip(EM), where EM is the encode...
python
def pkcs_emsa_pss_encode(M, emBits, h, mgf, sLen): """ Implements EMSA-PSS-ENCODE() function described in Sect. 9.1.1 of RFC 3447 Input: M : message to be encoded, an octet string emBits: maximal bit length of the integer resulting of pkcs_os2ip(EM), where EM is the encode...
[ "def", "pkcs_emsa_pss_encode", "(", "M", ",", "emBits", ",", "h", ",", "mgf", ",", "sLen", ")", ":", "# 1) is not done", "hLen", "=", "_hashFuncParams", "[", "h", "]", "[", "0", "]", "# 2)", "hFunc", "=", "_hashFuncParams", "[", "h", "]", "[", "1", "...
Implements EMSA-PSS-ENCODE() function described in Sect. 9.1.1 of RFC 3447 Input: M : message to be encoded, an octet string emBits: maximal bit length of the integer resulting of pkcs_os2ip(EM), where EM is the encoded message, output of the function. h : hash function ...
[ "Implements", "EMSA", "-", "PSS", "-", "ENCODE", "()", "function", "described", "in", "Sect", ".", "9", ".", "1", ".", "1", "of", "RFC", "3447" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L198-L242
phaethon/kamene
kamene/crypto/cert.py
pkcs_emsa_pss_verify
def pkcs_emsa_pss_verify(M, EM, emBits, h, mgf, sLen): """ Implements EMSA-PSS-VERIFY() function described in Sect. 9.1.2 of RFC 3447 Input: M : message to be encoded, an octet string EM : encoded message, an octet string of length emLen = ceil(emBits/8) emBits: maximal bit leng...
python
def pkcs_emsa_pss_verify(M, EM, emBits, h, mgf, sLen): """ Implements EMSA-PSS-VERIFY() function described in Sect. 9.1.2 of RFC 3447 Input: M : message to be encoded, an octet string EM : encoded message, an octet string of length emLen = ceil(emBits/8) emBits: maximal bit leng...
[ "def", "pkcs_emsa_pss_verify", "(", "M", ",", "EM", ",", "emBits", ",", "h", ",", "mgf", ",", "sLen", ")", ":", "# 1) is not done", "hLen", "=", "_hashFuncParams", "[", "h", "]", "[", "0", "]", "# 2)", "hFunc", "=", "_hashFuncParams", "[", "h", "]", ...
Implements EMSA-PSS-VERIFY() function described in Sect. 9.1.2 of RFC 3447 Input: M : message to be encoded, an octet string EM : encoded message, an octet string of length emLen = ceil(emBits/8) emBits: maximal bit length of the integer resulting of pkcs_os2ip(EM) h : hash f...
[ "Implements", "EMSA", "-", "PSS", "-", "VERIFY", "()", "function", "described", "in", "Sect", ".", "9", ".", "1", ".", "2", "of", "RFC", "3447" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L245-L301
phaethon/kamene
kamene/crypto/cert.py
pkcs_emsa_pkcs1_v1_5_encode
def pkcs_emsa_pkcs1_v1_5_encode(M, emLen, h): # section 9.2 of RFC 3447 """ Implements EMSA-PKCS1-V1_5-ENCODE() function described in Sect. 9.2 of RFC 3447. Input: M : message to be encode, an octet string emLen: intended length in octets of the encoded message, at least ...
python
def pkcs_emsa_pkcs1_v1_5_encode(M, emLen, h): # section 9.2 of RFC 3447 """ Implements EMSA-PKCS1-V1_5-ENCODE() function described in Sect. 9.2 of RFC 3447. Input: M : message to be encode, an octet string emLen: intended length in octets of the encoded message, at least ...
[ "def", "pkcs_emsa_pkcs1_v1_5_encode", "(", "M", ",", "emLen", ",", "h", ")", ":", "# section 9.2 of RFC 3447", "hLen", "=", "_hashFuncParams", "[", "h", "]", "[", "0", "]", "# 1)", "hFunc", "=", "_hashFuncParams", "[", "h", "]", "[", "1", "]", "H", "=", ...
Implements EMSA-PKCS1-V1_5-ENCODE() function described in Sect. 9.2 of RFC 3447. Input: M : message to be encode, an octet string emLen: intended length in octets of the encoded message, at least tLen + 11, where tLen is the octet length of the DER encoding T of a c...
[ "Implements", "EMSA", "-", "PKCS1", "-", "V1_5", "-", "ENCODE", "()", "function", "described", "in", "Sect", ".", "9", ".", "2", "of", "RFC", "3447", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L304-L334
phaethon/kamene
kamene/crypto/cert.py
create_ca_file
def create_ca_file(anchor_list, filename): """ Concatenate all the certificates (PEM format for the export) in 'anchor_list' and write the result to file 'filename'. On success 'filename' is returned, None otherwise. If you are used to OpenSSL tools, this function builds a CAfile that can be us...
python
def create_ca_file(anchor_list, filename): """ Concatenate all the certificates (PEM format for the export) in 'anchor_list' and write the result to file 'filename'. On success 'filename' is returned, None otherwise. If you are used to OpenSSL tools, this function builds a CAfile that can be us...
[ "def", "create_ca_file", "(", "anchor_list", ",", "filename", ")", ":", "try", ":", "f", "=", "open", "(", "filename", ",", "\"w\"", ")", "for", "a", "in", "anchor_list", ":", "s", "=", "a", ".", "output", "(", "fmt", "=", "\"PEM\"", ")", "f", ".",...
Concatenate all the certificates (PEM format for the export) in 'anchor_list' and write the result to file 'filename'. On success 'filename' is returned, None otherwise. If you are used to OpenSSL tools, this function builds a CAfile that can be used for certificate and CRL check. Also see create_...
[ "Concatenate", "all", "the", "certificates", "(", "PEM", "format", "for", "the", "export", ")", "in", "anchor_list", "and", "write", "the", "result", "to", "file", "filename", ".", "On", "success", "filename", "is", "returned", "None", "otherwise", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L339-L358
phaethon/kamene
kamene/crypto/cert.py
create_temporary_ca_file
def create_temporary_ca_file(anchor_list): """ Concatenate all the certificates (PEM format for the export) in 'anchor_list' and write the result to file to a temporary file using mkstemp() from tempfile module. On success 'filename' is returned, None otherwise. If you are used to OpenSSL tools...
python
def create_temporary_ca_file(anchor_list): """ Concatenate all the certificates (PEM format for the export) in 'anchor_list' and write the result to file to a temporary file using mkstemp() from tempfile module. On success 'filename' is returned, None otherwise. If you are used to OpenSSL tools...
[ "def", "create_temporary_ca_file", "(", "anchor_list", ")", ":", "try", ":", "f", ",", "fname", "=", "tempfile", ".", "mkstemp", "(", ")", "for", "a", "in", "anchor_list", ":", "s", "=", "a", ".", "output", "(", "fmt", "=", "\"PEM\"", ")", "l", "=", ...
Concatenate all the certificates (PEM format for the export) in 'anchor_list' and write the result to file to a temporary file using mkstemp() from tempfile module. On success 'filename' is returned, None otherwise. If you are used to OpenSSL tools, this function builds a CAfile that can be used fo...
[ "Concatenate", "all", "the", "certificates", "(", "PEM", "format", "for", "the", "export", ")", "in", "anchor_list", "and", "write", "the", "result", "to", "file", "to", "a", "temporary", "file", "using", "mkstemp", "()", "from", "tempfile", "module", ".", ...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L360-L380
phaethon/kamene
kamene/crypto/cert.py
create_temporary_ca_path
def create_temporary_ca_path(anchor_list, folder): """ Create a CA path folder as defined in OpenSSL terminology, by storing all certificates in 'anchor_list' list in PEM format under provided 'folder' and then creating the associated links using the hash as usually done by c_rehash. Note that ...
python
def create_temporary_ca_path(anchor_list, folder): """ Create a CA path folder as defined in OpenSSL terminology, by storing all certificates in 'anchor_list' list in PEM format under provided 'folder' and then creating the associated links using the hash as usually done by c_rehash. Note that ...
[ "def", "create_temporary_ca_path", "(", "anchor_list", ",", "folder", ")", ":", "# We should probably avoid writing duplicate anchors and also", "# check if they are all certs.", "try", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "folder", ")", ":", "os", ...
Create a CA path folder as defined in OpenSSL terminology, by storing all certificates in 'anchor_list' list in PEM format under provided 'folder' and then creating the associated links using the hash as usually done by c_rehash. Note that you can also include CRL in 'anchor_list'. In that case, th...
[ "Create", "a", "CA", "path", "folder", "as", "defined", "in", "OpenSSL", "terminology", "by", "storing", "all", "certificates", "in", "anchor_list", "list", "in", "PEM", "format", "under", "provided", "folder", "and", "then", "creating", "the", "associated", "...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L382-L427
phaethon/kamene
kamene/crypto/cert.py
_EncryptAndVerify.encrypt
def encrypt(self, m, t=None, h=None, mgf=None, L=None): """ Encrypt message 'm' using 't' encryption scheme where 't' can be: - None: the message 'm' is directly applied the RSAEP encryption primitive, as described in PKCS#1 v2.1, i.e. RFC 3447 Sect 5.1.1. Simply...
python
def encrypt(self, m, t=None, h=None, mgf=None, L=None): """ Encrypt message 'm' using 't' encryption scheme where 't' can be: - None: the message 'm' is directly applied the RSAEP encryption primitive, as described in PKCS#1 v2.1, i.e. RFC 3447 Sect 5.1.1. Simply...
[ "def", "encrypt", "(", "self", ",", "m", ",", "t", "=", "None", ",", "h", "=", "None", ",", "mgf", "=", "None", ",", "L", "=", "None", ")", ":", "if", "h", "is", "not", "None", ":", "h", "=", "mapHashFunc", "(", "h", ")", "if", "t", "is", ...
Encrypt message 'm' using 't' encryption scheme where 't' can be: - None: the message 'm' is directly applied the RSAEP encryption primitive, as described in PKCS#1 v2.1, i.e. RFC 3447 Sect 5.1.1. Simply put, the message undergo a modular exponentiation using the...
[ "Encrypt", "message", "m", "using", "t", "encryption", "scheme", "where", "t", "can", "be", ":" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L446-L505
phaethon/kamene
kamene/crypto/cert.py
_EncryptAndVerify.verify
def verify(self, M, S, t=None, h=None, mgf=None, sLen=None): """ Verify alleged signature 'S' is indeed the signature of message 'M' using 't' signature scheme where 't' can be: - None: the alleged signature 'S' is directly applied the RSAVP1 signature primitive, as desc...
python
def verify(self, M, S, t=None, h=None, mgf=None, sLen=None): """ Verify alleged signature 'S' is indeed the signature of message 'M' using 't' signature scheme where 't' can be: - None: the alleged signature 'S' is directly applied the RSAVP1 signature primitive, as desc...
[ "def", "verify", "(", "self", ",", "M", ",", "S", ",", "t", "=", "None", ",", "h", "=", "None", ",", "mgf", "=", "None", ",", "sLen", "=", "None", ")", ":", "if", "h", "is", "not", "None", ":", "h", "=", "mapHashFunc", "(", "h", ")", "if", ...
Verify alleged signature 'S' is indeed the signature of message 'M' using 't' signature scheme where 't' can be: - None: the alleged signature 'S' is directly applied the RSAVP1 signature primitive, as described in PKCS#1 v2.1, i.e. RFC 3447 Sect 5.2.1. Simply put, the p...
[ "Verify", "alleged", "signature", "S", "is", "indeed", "the", "signature", "of", "message", "M", "using", "t", "signature", "scheme", "where", "t", "can", "be", ":" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L509-L570
phaethon/kamene
kamene/crypto/cert.py
_DecryptAndSignMethods._rsadp
def _rsadp(self, c): """ Internal method providing raw RSA decryption, i.e. simple modular exponentiation of the given ciphertext representative 'c', a long between 0 and n-1. This is the decryption primitive RSADP described in PKCS#1 v2.1, i.e. RFC 3447 Sect. 5.1.2. ...
python
def _rsadp(self, c): """ Internal method providing raw RSA decryption, i.e. simple modular exponentiation of the given ciphertext representative 'c', a long between 0 and n-1. This is the decryption primitive RSADP described in PKCS#1 v2.1, i.e. RFC 3447 Sect. 5.1.2. ...
[ "def", "_rsadp", "(", "self", ",", "c", ")", ":", "n", "=", "self", ".", "modulus", "if", "type", "(", "c", ")", "is", "int", ":", "c", "=", "long", "(", "c", ")", "if", "type", "(", "c", ")", "is", "not", "long", "or", "c", ">", "n", "-"...
Internal method providing raw RSA decryption, i.e. simple modular exponentiation of the given ciphertext representative 'c', a long between 0 and n-1. This is the decryption primitive RSADP described in PKCS#1 v2.1, i.e. RFC 3447 Sect. 5.1.2. Input: c: ciphertest rep...
[ "Internal", "method", "providing", "raw", "RSA", "decryption", "i", ".", "e", ".", "simple", "modular", "exponentiation", "of", "the", "given", "ciphertext", "representative", "c", "a", "long", "between", "0", "and", "n", "-", "1", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L576-L602
phaethon/kamene
kamene/crypto/cert.py
_DecryptAndSignMethods._rsaes_pkcs1_v1_5_decrypt
def _rsaes_pkcs1_v1_5_decrypt(self, C): """ Implements RSAES-PKCS1-V1_5-DECRYPT() function described in section 7.2.2 of RFC 3447. Input: C: ciphertext to be decrypted, an octet string of length k, where k is the length in octets of the RSA modulus n. O...
python
def _rsaes_pkcs1_v1_5_decrypt(self, C): """ Implements RSAES-PKCS1-V1_5-DECRYPT() function described in section 7.2.2 of RFC 3447. Input: C: ciphertext to be decrypted, an octet string of length k, where k is the length in octets of the RSA modulus n. O...
[ "def", "_rsaes_pkcs1_v1_5_decrypt", "(", "self", ",", "C", ")", ":", "# 1) Length checking", "cLen", "=", "len", "(", "C", ")", "k", "=", "self", ".", "modulusLen", "/", "8", "if", "cLen", "!=", "k", "or", "k", "<", "11", ":", "warning", "(", "\"Key....
Implements RSAES-PKCS1-V1_5-DECRYPT() function described in section 7.2.2 of RFC 3447. Input: C: ciphertext to be decrypted, an octet string of length k, where k is the length in octets of the RSA modulus n. Output: an octet string of length k at most k - 11...
[ "Implements", "RSAES", "-", "PKCS1", "-", "V1_5", "-", "DECRYPT", "()", "function", "described", "in", "section", "7", ".", "2", ".", "2", "of", "RFC", "3447", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L605-L661
phaethon/kamene
kamene/crypto/cert.py
_DecryptAndSignMethods._rsaes_oaep_decrypt
def _rsaes_oaep_decrypt(self, C, h=None, mgf=None, L=None): """ Internal method providing RSAES-OAEP-DECRYPT as defined in Sect. 7.1.2 of RFC 3447. Not intended to be used directly. Please, see encrypt() method for type "OAEP". Input: C : ciphertext to be decrypted,...
python
def _rsaes_oaep_decrypt(self, C, h=None, mgf=None, L=None): """ Internal method providing RSAES-OAEP-DECRYPT as defined in Sect. 7.1.2 of RFC 3447. Not intended to be used directly. Please, see encrypt() method for type "OAEP". Input: C : ciphertext to be decrypted,...
[ "def", "_rsaes_oaep_decrypt", "(", "self", ",", "C", ",", "h", "=", "None", ",", "mgf", "=", "None", ",", "L", "=", "None", ")", ":", "# The steps below are the one described in Sect. 7.1.2 of RFC 3447.", "# 1) Length Checking", "# 1.a) is not done", "if", "h", "is"...
Internal method providing RSAES-OAEP-DECRYPT as defined in Sect. 7.1.2 of RFC 3447. Not intended to be used directly. Please, see encrypt() method for type "OAEP". Input: C : ciphertext to be decrypted, an octet string of length k, where k = 2*hLen + 2 (k denotes th...
[ "Internal", "method", "providing", "RSAES", "-", "OAEP", "-", "DECRYPT", "as", "defined", "in", "Sect", ".", "7", ".", "1", ".", "2", "of", "RFC", "3447", ".", "Not", "intended", "to", "be", "used", "directly", ".", "Please", "see", "encrypt", "()", ...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L664-L751
phaethon/kamene
kamene/crypto/cert.py
_DecryptAndSignMethods.decrypt
def decrypt(self, C, t=None, h=None, mgf=None, L=None): """ Decrypt ciphertext 'C' using 't' decryption scheme where 't' can be: - None: the ciphertext 'C' is directly applied the RSADP decryption primitive, as described in PKCS#1 v2.1, i.e. RFC 3447 Sect 5.1.2. ...
python
def decrypt(self, C, t=None, h=None, mgf=None, L=None): """ Decrypt ciphertext 'C' using 't' decryption scheme where 't' can be: - None: the ciphertext 'C' is directly applied the RSADP decryption primitive, as described in PKCS#1 v2.1, i.e. RFC 3447 Sect 5.1.2. ...
[ "def", "decrypt", "(", "self", ",", "C", ",", "t", "=", "None", ",", "h", "=", "None", ",", "mgf", "=", "None", ",", "L", "=", "None", ")", ":", "if", "t", "is", "None", ":", "C", "=", "pkcs_os2ip", "(", "C", ")", "c", "=", "self", ".", "...
Decrypt ciphertext 'C' using 't' decryption scheme where 't' can be: - None: the ciphertext 'C' is directly applied the RSADP decryption primitive, as described in PKCS#1 v2.1, i.e. RFC 3447 Sect 5.1.2. Simply, put the message undergo a modular exponentiation usi...
[ "Decrypt", "ciphertext", "C", "using", "t", "decryption", "scheme", "where", "t", "can", "be", ":" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L754-L802
phaethon/kamene
kamene/crypto/cert.py
_DecryptAndSignMethods._rsassa_pss_sign
def _rsassa_pss_sign(self, M, h=None, mgf=None, sLen=None): """ Implements RSASSA-PSS-SIGN() function described in Sect. 8.1.1 of RFC 3447. Input: M: message to be signed, an octet string Output: signature, an octet string of length k, where k is the lengt...
python
def _rsassa_pss_sign(self, M, h=None, mgf=None, sLen=None): """ Implements RSASSA-PSS-SIGN() function described in Sect. 8.1.1 of RFC 3447. Input: M: message to be signed, an octet string Output: signature, an octet string of length k, where k is the lengt...
[ "def", "_rsassa_pss_sign", "(", "self", ",", "M", ",", "h", "=", "None", ",", "mgf", "=", "None", ",", "sLen", "=", "None", ")", ":", "# Set default parameters if not provided", "if", "h", "is", "None", ":", "# By default, sha1", "h", "=", "\"sha1\"", "if"...
Implements RSASSA-PSS-SIGN() function described in Sect. 8.1.1 of RFC 3447. Input: M: message to be signed, an octet string Output: signature, an octet string of length k, where k is the length in octets of the RSA modulus n. On error, None is returned...
[ "Implements", "RSASSA", "-", "PSS", "-", "SIGN", "()", "function", "described", "in", "Sect", ".", "8", ".", "1", ".", "1", "of", "RFC", "3447", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L828-L869
phaethon/kamene
kamene/crypto/cert.py
_DecryptAndSignMethods._rsassa_pkcs1_v1_5_sign
def _rsassa_pkcs1_v1_5_sign(self, M, h): """ Implements RSASSA-PKCS1-v1_5-SIGN() function as described in Sect. 8.2.1 of RFC 3447. Input: M: message to be signed, an octet string h: hash function name (in 'md2', 'md4', 'md5', 'sha1', 'tls' 'sha256',...
python
def _rsassa_pkcs1_v1_5_sign(self, M, h): """ Implements RSASSA-PKCS1-v1_5-SIGN() function as described in Sect. 8.2.1 of RFC 3447. Input: M: message to be signed, an octet string h: hash function name (in 'md2', 'md4', 'md5', 'sha1', 'tls' 'sha256',...
[ "def", "_rsassa_pkcs1_v1_5_sign", "(", "self", ",", "M", ",", "h", ")", ":", "# 1) EMSA-PKCS1-v1_5 encoding", "k", "=", "self", ".", "modulusLen", "/", "8", "EM", "=", "pkcs_emsa_pkcs1_v1_5_encode", "(", "M", ",", "k", ",", "h", ")", "if", "EM", "is", "N...
Implements RSASSA-PKCS1-v1_5-SIGN() function as described in Sect. 8.2.1 of RFC 3447. Input: M: message to be signed, an octet string h: hash function name (in 'md2', 'md4', 'md5', 'sha1', 'tls' 'sha256', 'sha384'). Output: the signat...
[ "Implements", "RSASSA", "-", "PKCS1", "-", "v1_5", "-", "SIGN", "()", "function", "as", "described", "in", "Sect", ".", "8", ".", "2", ".", "1", "of", "RFC", "3447", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L872-L898
phaethon/kamene
kamene/crypto/cert.py
_DecryptAndSignMethods.sign
def sign(self, M, t=None, h=None, mgf=None, sLen=None): """ Sign message 'M' using 't' signature scheme where 't' can be: - None: the message 'M' is directly applied the RSASP1 signature primitive, as described in PKCS#1 v2.1, i.e. RFC 3447 Sect 5.2.1. Simply put...
python
def sign(self, M, t=None, h=None, mgf=None, sLen=None): """ Sign message 'M' using 't' signature scheme where 't' can be: - None: the message 'M' is directly applied the RSASP1 signature primitive, as described in PKCS#1 v2.1, i.e. RFC 3447 Sect 5.2.1. Simply put...
[ "def", "sign", "(", "self", ",", "M", ",", "t", "=", "None", ",", "h", "=", "None", ",", "mgf", "=", "None", ",", "sLen", "=", "None", ")", ":", "if", "t", "is", "None", ":", "# RSASP1", "M", "=", "pkcs_os2ip", "(", "M", ")", "n", "=", "sel...
Sign message 'M' using 't' signature scheme where 't' can be: - None: the message 'M' is directly applied the RSASP1 signature primitive, as described in PKCS#1 v2.1, i.e. RFC 3447 Sect 5.2.1. Simply put, the message undergo a modular exponentiation using the pri...
[ "Sign", "message", "M", "using", "t", "signature", "scheme", "where", "t", "can", "be", ":" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L901-L956
phaethon/kamene
kamene/crypto/cert.py
Cert.isIssuerCert
def isIssuerCert(self, other): """ True if 'other' issued 'self', i.e.: - self.issuer == other.subject - self is signed by other """ # XXX should be done on raw values, instead of their textual repr if self.issuer != other.subject: return False ...
python
def isIssuerCert(self, other): """ True if 'other' issued 'self', i.e.: - self.issuer == other.subject - self is signed by other """ # XXX should be done on raw values, instead of their textual repr if self.issuer != other.subject: return False ...
[ "def", "isIssuerCert", "(", "self", ",", "other", ")", ":", "# XXX should be done on raw values, instead of their textual repr", "if", "self", ".", "issuer", "!=", "other", ".", "subject", ":", "return", "False", "# Sanity check regarding modulus length and the", "# signatu...
True if 'other' issued 'self', i.e.: - self.issuer == other.subject - self is signed by other
[ "True", "if", "other", "issued", "self", "i", ".", "e", ".", ":", "-", "self", ".", "issuer", "==", "other", ".", "subject", "-", "self", "is", "signed", "by", "other" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L1726-L1769
phaethon/kamene
kamene/crypto/cert.py
Cert.chain
def chain(self, certlist): """ Construct the chain of certificates leading from 'self' to the self signed root using the certificates in 'certlist'. If the list does not provide all the required certs to go to the root the function returns a incomplete chain starting with the ...
python
def chain(self, certlist): """ Construct the chain of certificates leading from 'self' to the self signed root using the certificates in 'certlist'. If the list does not provide all the required certs to go to the root the function returns a incomplete chain starting with the ...
[ "def", "chain", "(", "self", ",", "certlist", ")", ":", "d", "=", "{", "}", "for", "c", "in", "certlist", ":", "# XXX we should check if we have duplicate", "d", "[", "c", ".", "subject", "]", "=", "c", "res", "=", "[", "self", "]", "cur", "=", "self...
Construct the chain of certificates leading from 'self' to the self signed root using the certificates in 'certlist'. If the list does not provide all the required certs to go to the root the function returns a incomplete chain starting with the certificate. This fact can be tested by tc...
[ "Construct", "the", "chain", "of", "certificates", "leading", "from", "self", "to", "the", "self", "signed", "root", "using", "the", "certificates", "in", "certlist", ".", "If", "the", "list", "does", "not", "provide", "all", "the", "required", "certs", "to"...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L1771-L1795
phaethon/kamene
kamene/crypto/cert.py
Cert.remainingDays
def remainingDays(self, now=None): """ Based on the value of notBefore field, returns the number of days the certificate will still be valid. The date used for the comparison is the current and local date, as returned by time.localtime(), except if 'now' argument is provided ano...
python
def remainingDays(self, now=None): """ Based on the value of notBefore field, returns the number of days the certificate will still be valid. The date used for the comparison is the current and local date, as returned by time.localtime(), except if 'now' argument is provided ano...
[ "def", "remainingDays", "(", "self", ",", "now", "=", "None", ")", ":", "if", "now", "is", "None", ":", "now", "=", "time", ".", "localtime", "(", ")", "elif", "type", "(", "now", ")", "is", "str", ":", "try", ":", "if", "'/'", "in", "now", ":"...
Based on the value of notBefore field, returns the number of days the certificate will still be valid. The date used for the comparison is the current and local date, as returned by time.localtime(), except if 'now' argument is provided another one. 'now' argument can be given as either...
[ "Based", "on", "the", "value", "of", "notBefore", "field", "returns", "the", "number", "of", "days", "the", "certificate", "will", "still", "be", "valid", ".", "The", "date", "used", "for", "the", "comparison", "is", "the", "current", "and", "local", "date...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L1797-L1832
phaethon/kamene
kamene/crypto/cert.py
Cert.export
def export(self, filename, fmt="DER"): """ Export certificate in 'fmt' format (PEM, DER or TXT) to file 'filename' """ f = open(filename, "wb") f.write(self.output(fmt)) f.close()
python
def export(self, filename, fmt="DER"): """ Export certificate in 'fmt' format (PEM, DER or TXT) to file 'filename' """ f = open(filename, "wb") f.write(self.output(fmt)) f.close()
[ "def", "export", "(", "self", ",", "filename", ",", "fmt", "=", "\"DER\"", ")", ":", "f", "=", "open", "(", "filename", ",", "\"wb\"", ")", "f", ".", "write", "(", "self", ".", "output", "(", "fmt", ")", ")", "f", ".", "close", "(", ")" ]
Export certificate in 'fmt' format (PEM, DER or TXT) to file 'filename'
[ "Export", "certificate", "in", "fmt", "format", "(", "PEM", "DER", "or", "TXT", ")", "to", "file", "filename" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L1855-L1861
phaethon/kamene
kamene/crypto/cert.py
Cert.isSelfSigned
def isSelfSigned(self): """ Return True if the certificate is self signed: - issuer and subject are the same - the signature of the certificate is valid. """ if self.issuer == self.subject: return self.isIssuerCert(self) return False
python
def isSelfSigned(self): """ Return True if the certificate is self signed: - issuer and subject are the same - the signature of the certificate is valid. """ if self.issuer == self.subject: return self.isIssuerCert(self) return False
[ "def", "isSelfSigned", "(", "self", ")", ":", "if", "self", ".", "issuer", "==", "self", ".", "subject", ":", "return", "self", ".", "isIssuerCert", "(", "self", ")", "return", "False" ]
Return True if the certificate is self signed: - issuer and subject are the same - the signature of the certificate is valid.
[ "Return", "True", "if", "the", "certificate", "is", "self", "signed", ":", "-", "issuer", "and", "subject", "are", "the", "same", "-", "the", "signature", "of", "the", "certificate", "is", "valid", "." ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L1863-L1871
phaethon/kamene
kamene/crypto/cert.py
Cert.verifychain
def verifychain(self, anchors, untrusted=None): """ Perform verification of certificate chains for that certificate. The behavior of verifychain method is mapped (and also based) on openssl verify userland tool (man 1 verify). A list of anchors is required. untrusted parameter ca...
python
def verifychain(self, anchors, untrusted=None): """ Perform verification of certificate chains for that certificate. The behavior of verifychain method is mapped (and also based) on openssl verify userland tool (man 1 verify). A list of anchors is required. untrusted parameter ca...
[ "def", "verifychain", "(", "self", ",", "anchors", ",", "untrusted", "=", "None", ")", ":", "cafile", "=", "create_temporary_ca_file", "(", "anchors", ")", "if", "not", "cafile", ":", "return", "False", "untrusted_file", "=", "None", "if", "untrusted", ":", ...
Perform verification of certificate chains for that certificate. The behavior of verifychain method is mapped (and also based) on openssl verify userland tool (man 1 verify). A list of anchors is required. untrusted parameter can be provided a list of untrusted certificates that can be ...
[ "Perform", "verification", "of", "certificate", "chains", "for", "that", "certificate", ".", "The", "behavior", "of", "verifychain", "method", "is", "mapped", "(", "and", "also", "based", ")", "on", "openssl", "verify", "userland", "tool", "(", "man", "1", "...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L1887-L1914
phaethon/kamene
kamene/crypto/cert.py
Cert.verifychain_from_cafile
def verifychain_from_cafile(self, cafile, untrusted_file=None): """ Does the same job as .verifychain() but using the list of anchors from the cafile. This is useful (because more efficient) if you have a lot of certificates to verify do it that way: it avoids the creation of a c...
python
def verifychain_from_cafile(self, cafile, untrusted_file=None): """ Does the same job as .verifychain() but using the list of anchors from the cafile. This is useful (because more efficient) if you have a lot of certificates to verify do it that way: it avoids the creation of a c...
[ "def", "verifychain_from_cafile", "(", "self", ",", "cafile", ",", "untrusted_file", "=", "None", ")", ":", "cmd", "=", "[", "\"openssl\"", ",", "\"verify\"", ",", "\"-CAfile\"", ",", "cafile", "]", "if", "untrusted_file", ":", "cmd", "+=", "[", "\"-untruste...
Does the same job as .verifychain() but using the list of anchors from the cafile. This is useful (because more efficient) if you have a lot of certificates to verify do it that way: it avoids the creation of a cafile from anchors at each call. As for .verifychain(), a list of untrusted...
[ "Does", "the", "same", "job", "as", ".", "verifychain", "()", "but", "using", "the", "list", "of", "anchors", "from", "the", "cafile", ".", "This", "is", "useful", "(", "because", "more", "efficient", ")", "if", "you", "have", "a", "lot", "of", "certif...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L1916-L1934
phaethon/kamene
kamene/crypto/cert.py
Cert.verifychain_from_capath
def verifychain_from_capath(self, capath, untrusted_file=None): """ Does the same job as .verifychain_from_cafile() but using the list of anchors in capath directory. The directory should contain certificates files in PEM format with associated links as created using c_rehash uti...
python
def verifychain_from_capath(self, capath, untrusted_file=None): """ Does the same job as .verifychain_from_cafile() but using the list of anchors in capath directory. The directory should contain certificates files in PEM format with associated links as created using c_rehash uti...
[ "def", "verifychain_from_capath", "(", "self", ",", "capath", ",", "untrusted_file", "=", "None", ")", ":", "cmd", "=", "[", "\"openssl\"", ",", "\"verify\"", ",", "\"-CApath\"", ",", "capath", "]", "if", "untrusted_file", ":", "cmd", "+=", "[", "\"-untruste...
Does the same job as .verifychain_from_cafile() but using the list of anchors in capath directory. The directory should contain certificates files in PEM format with associated links as created using c_rehash utility (man c_rehash). As for .verifychain_from_cafile(), a list of untrusted...
[ "Does", "the", "same", "job", "as", ".", "verifychain_from_cafile", "()", "but", "using", "the", "list", "of", "anchors", "in", "capath", "directory", ".", "The", "directory", "should", "contain", "certificates", "files", "in", "PEM", "format", "with", "associ...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L1936-L1955
phaethon/kamene
kamene/crypto/cert.py
Cert.is_revoked
def is_revoked(self, crl_list): """ Given a list of trusted CRL (their signature has already been verified with trusted anchors), this function returns True if the certificate is marked as revoked by one of those CRL. Note that if the Certificate was on hold in a previous CRL an...
python
def is_revoked(self, crl_list): """ Given a list of trusted CRL (their signature has already been verified with trusted anchors), this function returns True if the certificate is marked as revoked by one of those CRL. Note that if the Certificate was on hold in a previous CRL an...
[ "def", "is_revoked", "(", "self", ",", "crl_list", ")", ":", "for", "c", "in", "crl_list", ":", "if", "(", "self", ".", "authorityKeyID", "is", "not", "None", "and", "c", ".", "authorityKeyID", "is", "not", "None", "and", "self", ".", "authorityKeyID", ...
Given a list of trusted CRL (their signature has already been verified with trusted anchors), this function returns True if the certificate is marked as revoked by one of those CRL. Note that if the Certificate was on hold in a previous CRL and is now valid again in a new CRL and bot ar...
[ "Given", "a", "list", "of", "trusted", "CRL", "(", "their", "signature", "has", "already", "been", "verified", "with", "trusted", "anchors", ")", "this", "function", "returns", "True", "if", "the", "certificate", "is", "marked", "as", "revoked", "by", "one",...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L1957-L1980
phaethon/kamene
kamene/crypto/cert.py
CRL.verify
def verify(self, anchors): """ Return True if the CRL is signed by one of the provided anchors. False on error (invalid signature, missing anchorand, ...) """ cafile = create_temporary_ca_file(anchors) if cafile is None: return False try: c...
python
def verify(self, anchors): """ Return True if the CRL is signed by one of the provided anchors. False on error (invalid signature, missing anchorand, ...) """ cafile = create_temporary_ca_file(anchors) if cafile is None: return False try: c...
[ "def", "verify", "(", "self", ",", "anchors", ")", ":", "cafile", "=", "create_temporary_ca_file", "(", "anchors", ")", "if", "cafile", "is", "None", ":", "return", "False", "try", ":", "cmd", "=", "self", ".", "osslcmdbase", "+", "[", "\"-noout\"", ",",...
Return True if the CRL is signed by one of the provided anchors. False on error (invalid signature, missing anchorand, ...)
[ "Return", "True", "if", "the", "CRL", "is", "signed", "by", "one", "of", "the", "provided", "anchors", ".", "False", "on", "error", "(", "invalid", "signature", "missing", "anchorand", "...", ")" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L2276-L2291
phaethon/kamene
kamene/sendrecv.py
send
def send(x, inter=0, loop=0, count=None, verbose=None, realtime=None, *args, **kargs): """Send packets at layer 3 send(packets, [inter=0], [loop=0], [verbose=conf.verb]) -> None""" __gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose, realtime=realtime)
python
def send(x, inter=0, loop=0, count=None, verbose=None, realtime=None, *args, **kargs): """Send packets at layer 3 send(packets, [inter=0], [loop=0], [verbose=conf.verb]) -> None""" __gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose, realtime=realtime)
[ "def", "send", "(", "x", ",", "inter", "=", "0", ",", "loop", "=", "0", ",", "count", "=", "None", ",", "verbose", "=", "None", ",", "realtime", "=", "None", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "__gen_send", "(", "conf", ".", ...
Send packets at layer 3 send(packets, [inter=0], [loop=0], [verbose=conf.verb]) -> None
[ "Send", "packets", "at", "layer", "3", "send", "(", "packets", "[", "inter", "=", "0", "]", "[", "loop", "=", "0", "]", "[", "verbose", "=", "conf", ".", "verb", "]", ")", "-", ">", "None" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/sendrecv.py#L257-L260
phaethon/kamene
kamene/sendrecv.py
sendp
def sendp(x, inter=0, loop=0, iface=None, iface_hint=None, count=None, verbose=None, realtime=None, *args, **kargs): """Send packets at layer 2 sendp(packets, [inter=0], [loop=0], [verbose=conf.verb]) -> None""" if iface is None and iface_hint is not None: iface = conf.route.route(iface_hint)[0] __g...
python
def sendp(x, inter=0, loop=0, iface=None, iface_hint=None, count=None, verbose=None, realtime=None, *args, **kargs): """Send packets at layer 2 sendp(packets, [inter=0], [loop=0], [verbose=conf.verb]) -> None""" if iface is None and iface_hint is not None: iface = conf.route.route(iface_hint)[0] __g...
[ "def", "sendp", "(", "x", ",", "inter", "=", "0", ",", "loop", "=", "0", ",", "iface", "=", "None", ",", "iface_hint", "=", "None", ",", "count", "=", "None", ",", "verbose", "=", "None", ",", "realtime", "=", "None", ",", "*", "args", ",", "*"...
Send packets at layer 2 sendp(packets, [inter=0], [loop=0], [verbose=conf.verb]) -> None
[ "Send", "packets", "at", "layer", "2", "sendp", "(", "packets", "[", "inter", "=", "0", "]", "[", "loop", "=", "0", "]", "[", "verbose", "=", "conf", ".", "verb", "]", ")", "-", ">", "None" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/sendrecv.py#L263-L268
phaethon/kamene
kamene/sendrecv.py
sendpfast
def sendpfast(x, pps=None, mbps=None, realtime=None, loop=0, file_cache=False, iface=None, verbose=True): """Send packets at layer 2 using tcpreplay for performance pps: packets per second mpbs: MBits per second realtime: use packet's timestamp, bending time with realtime value loop: number of time...
python
def sendpfast(x, pps=None, mbps=None, realtime=None, loop=0, file_cache=False, iface=None, verbose=True): """Send packets at layer 2 using tcpreplay for performance pps: packets per second mpbs: MBits per second realtime: use packet's timestamp, bending time with realtime value loop: number of time...
[ "def", "sendpfast", "(", "x", ",", "pps", "=", "None", ",", "mbps", "=", "None", ",", "realtime", "=", "None", ",", "loop", "=", "0", ",", "file_cache", "=", "False", ",", "iface", "=", "None", ",", "verbose", "=", "True", ")", ":", "if", "iface"...
Send packets at layer 2 using tcpreplay for performance pps: packets per second mpbs: MBits per second realtime: use packet's timestamp, bending time with realtime value loop: number of times to process the packet list file_cache: cache packets in RAM instead of reading from disk at each iteration ...
[ "Send", "packets", "at", "layer", "2", "using", "tcpreplay", "for", "performance", "pps", ":", "packets", "per", "second", "mpbs", ":", "MBits", "per", "second", "realtime", ":", "use", "packet", "s", "timestamp", "bending", "time", "with", "realtime", "valu...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/sendrecv.py#L271-L312
phaethon/kamene
kamene/sendrecv.py
sr
def sr(x,filter=None, iface=None, nofilter=0, *args,**kargs): """Send and receive packets at layer 3 nofilter: put 1 to avoid use of bpf filters retry: if positive, how many times to resend unanswered packets if negative, how many times to retry when no more packets are answered timeout: how much time...
python
def sr(x,filter=None, iface=None, nofilter=0, *args,**kargs): """Send and receive packets at layer 3 nofilter: put 1 to avoid use of bpf filters retry: if positive, how many times to resend unanswered packets if negative, how many times to retry when no more packets are answered timeout: how much time...
[ "def", "sr", "(", "x", ",", "filter", "=", "None", ",", "iface", "=", "None", ",", "nofilter", "=", "0", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "if", "not", "\"timeout\"", "in", "kargs", ":", "kargs", "[", "\"timeout\"", "]", "=", ...
Send and receive packets at layer 3 nofilter: put 1 to avoid use of bpf filters retry: if positive, how many times to resend unanswered packets if negative, how many times to retry when no more packets are answered timeout: how much time to wait after the last packet has been sent verbose: set verbosity ...
[ "Send", "and", "receive", "packets", "at", "layer", "3", "nofilter", ":", "put", "1", "to", "avoid", "use", "of", "bpf", "filters", "retry", ":", "if", "positive", "how", "many", "times", "to", "resend", "unanswered", "packets", "if", "negative", "how", ...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/sendrecv.py#L319-L334
phaethon/kamene
kamene/sendrecv.py
srp1
def srp1(*args,**kargs): """Send and receive packets at layer 2 and return only the first answer nofilter: put 1 to avoid use of bpf filters retry: if positive, how many times to resend unanswered packets if negative, how many times to retry when no more packets are answered timeout: how much time to ...
python
def srp1(*args,**kargs): """Send and receive packets at layer 2 and return only the first answer nofilter: put 1 to avoid use of bpf filters retry: if positive, how many times to resend unanswered packets if negative, how many times to retry when no more packets are answered timeout: how much time to ...
[ "def", "srp1", "(", "*", "args", ",", "*", "*", "kargs", ")", ":", "if", "not", "\"timeout\"", "in", "kargs", ":", "kargs", "[", "\"timeout\"", "]", "=", "-", "1", "a", ",", "b", "=", "srp", "(", "*", "args", ",", "*", "*", "kargs", ")", "if"...
Send and receive packets at layer 2 and return only the first answer nofilter: put 1 to avoid use of bpf filters retry: if positive, how many times to resend unanswered packets if negative, how many times to retry when no more packets are answered timeout: how much time to wait after the last packet has b...
[ "Send", "and", "receive", "packets", "at", "layer", "2", "and", "return", "only", "the", "first", "answer", "nofilter", ":", "put", "1", "to", "avoid", "use", "of", "bpf", "filters", "retry", ":", "if", "positive", "how", "many", "times", "to", "resend",...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/sendrecv.py#L378-L394
phaethon/kamene
kamene/sendrecv.py
sniff
def sniff(count=0, store=1, offline=None, prn = None, lfilter=None, L2socket=None, timeout=None, opened_socket=None, stop_filter=None, exceptions=False, stop_callback=None, *arg, **karg): """Sniff packets sniff([count=0,] [prn=None,] [store=1,] [offline=None,] [lfilter=None,] + L2ListenSocket args) -> lis...
python
def sniff(count=0, store=1, offline=None, prn = None, lfilter=None, L2socket=None, timeout=None, opened_socket=None, stop_filter=None, exceptions=False, stop_callback=None, *arg, **karg): """Sniff packets sniff([count=0,] [prn=None,] [store=1,] [offline=None,] [lfilter=None,] + L2ListenSocket args) -> lis...
[ "def", "sniff", "(", "count", "=", "0", ",", "store", "=", "1", ",", "offline", "=", "None", ",", "prn", "=", "None", ",", "lfilter", "=", "None", ",", "L2socket", "=", "None", ",", "timeout", "=", "None", ",", "opened_socket", "=", "None", ",", ...
Sniff packets sniff([count=0,] [prn=None,] [store=1,] [offline=None,] [lfilter=None,] + L2ListenSocket args) -> list of packets count: number of packets to capture. 0 means infinity store: wether to store sniffed packets or discard them prn: function to apply to each packet. If something is returned, ...
[ "Sniff", "packets", "sniff", "(", "[", "count", "=", "0", "]", "[", "prn", "=", "None", "]", "[", "store", "=", "1", "]", "[", "offline", "=", "None", "]", "[", "lfilter", "=", "None", "]", "+", "L2ListenSocket", "args", ")", "-", ">", "list", ...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/sendrecv.py#L549-L625
phaethon/kamene
kamene/sendrecv.py
bridge_and_sniff
def bridge_and_sniff(if1, if2, count=0, store=1, offline=None, prn = None, lfilter=None, L2socket=None, timeout=None, stop_filter=None, stop_callback=None, *args, **kargs): """Forward traffic between two interfaces and sniff packets exchanged bridge_and_sniff([count=0,] [prn=None,] [store=1,] [...
python
def bridge_and_sniff(if1, if2, count=0, store=1, offline=None, prn = None, lfilter=None, L2socket=None, timeout=None, stop_filter=None, stop_callback=None, *args, **kargs): """Forward traffic between two interfaces and sniff packets exchanged bridge_and_sniff([count=0,] [prn=None,] [store=1,] [...
[ "def", "bridge_and_sniff", "(", "if1", ",", "if2", ",", "count", "=", "0", ",", "store", "=", "1", ",", "offline", "=", "None", ",", "prn", "=", "None", ",", "lfilter", "=", "None", ",", "L2socket", "=", "None", ",", "timeout", "=", "None", ",", ...
Forward traffic between two interfaces and sniff packets exchanged bridge_and_sniff([count=0,] [prn=None,] [store=1,] [offline=None,] [lfilter=None,] + L2Socket args) -> list of packets count: number of packets to capture. 0 means infinity store: wether to store sniffed packets or discard them prn: function to...
[ "Forward", "traffic", "between", "two", "interfaces", "and", "sniff", "packets", "exchanged", "bridge_and_sniff", "(", "[", "count", "=", "0", "]", "[", "prn", "=", "None", "]", "[", "store", "=", "1", "]", "[", "offline", "=", "None", "]", "[", "lfilt...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/sendrecv.py#L629-L692
phaethon/kamene
kamene/sendrecv.py
tshark
def tshark(*args,**kargs): """Sniff packets and print them calling pkt.show(), a bit like text wireshark""" sniff(prn=lambda x: x.display(),*args,**kargs)
python
def tshark(*args,**kargs): """Sniff packets and print them calling pkt.show(), a bit like text wireshark""" sniff(prn=lambda x: x.display(),*args,**kargs)
[ "def", "tshark", "(", "*", "args", ",", "*", "*", "kargs", ")", ":", "sniff", "(", "prn", "=", "lambda", "x", ":", "x", ".", "display", "(", ")", ",", "*", "args", ",", "*", "*", "kargs", ")" ]
Sniff packets and print them calling pkt.show(), a bit like text wireshark
[ "Sniff", "packets", "and", "print", "them", "calling", "pkt", ".", "show", "()", "a", "bit", "like", "text", "wireshark" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/sendrecv.py#L696-L698
phaethon/kamene
kamene/layers/inet.py
fragment
def fragment(pkt, fragsize=1480): """Fragment a big IP datagram""" fragsize = (fragsize + 7) // 8 * 8 lst = [] for p in pkt: s = bytes(p[IP].payload) nb = (len(s) + fragsize - 1) // fragsize for i in range(nb): q = p.copy() del q[IP].payload de...
python
def fragment(pkt, fragsize=1480): """Fragment a big IP datagram""" fragsize = (fragsize + 7) // 8 * 8 lst = [] for p in pkt: s = bytes(p[IP].payload) nb = (len(s) + fragsize - 1) // fragsize for i in range(nb): q = p.copy() del q[IP].payload de...
[ "def", "fragment", "(", "pkt", ",", "fragsize", "=", "1480", ")", ":", "fragsize", "=", "(", "fragsize", "+", "7", ")", "//", "8", "*", "8", "lst", "=", "[", "]", "for", "p", "in", "pkt", ":", "s", "=", "bytes", "(", "p", "[", "IP", "]", "....
Fragment a big IP datagram
[ "Fragment", "a", "big", "IP", "datagram" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet.py#L864-L885
phaethon/kamene
kamene/layers/inet.py
defrag
def defrag(plist): """defrag(plist) -> ([not fragmented], [defragmented], [ [bad fragments], [bad fragments], ... ])""" frags = defaultdict(PacketList) nofrag = PacketList() for p in plist: ip = p[IP] if IP not in p: nofrag.append(p) continue ...
python
def defrag(plist): """defrag(plist) -> ([not fragmented], [defragmented], [ [bad fragments], [bad fragments], ... ])""" frags = defaultdict(PacketList) nofrag = PacketList() for p in plist: ip = p[IP] if IP not in p: nofrag.append(p) continue ...
[ "def", "defrag", "(", "plist", ")", ":", "frags", "=", "defaultdict", "(", "PacketList", ")", "nofrag", "=", "PacketList", "(", ")", "for", "p", "in", "plist", ":", "ip", "=", "p", "[", "IP", "]", "if", "IP", "not", "in", "p", ":", "nofrag", ".",...
defrag(plist) -> ([not fragmented], [defragmented], [ [bad fragments], [bad fragments], ... ])
[ "defrag", "(", "plist", ")", "-", ">", "(", "[", "not", "fragmented", "]", "[", "defragmented", "]", "[", "[", "bad", "fragments", "]", "[", "bad", "fragments", "]", "...", "]", ")" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet.py#L901-L956
phaethon/kamene
kamene/layers/inet.py
_packetlist_timeskew_graph
def _packetlist_timeskew_graph(self, ip, **kargs): """Tries to graph the timeskew between the timestamps and real time for a given ip""" res = map(lambda x: self._elt2pkt(x), self.res) b = filter(lambda x: x.haslayer(IP) and x.getlayer(IP).src == ip and x.haslayer(TCP), res) c = [] for p in b: ...
python
def _packetlist_timeskew_graph(self, ip, **kargs): """Tries to graph the timeskew between the timestamps and real time for a given ip""" res = map(lambda x: self._elt2pkt(x), self.res) b = filter(lambda x: x.haslayer(IP) and x.getlayer(IP).src == ip and x.haslayer(TCP), res) c = [] for p in b: ...
[ "def", "_packetlist_timeskew_graph", "(", "self", ",", "ip", ",", "*", "*", "kargs", ")", ":", "res", "=", "map", "(", "lambda", "x", ":", "self", ".", "_elt2pkt", "(", "x", ")", ",", "self", ".", "res", ")", "b", "=", "filter", "(", "lambda", "x...
Tries to graph the timeskew between the timestamps and real time for a given ip
[ "Tries", "to", "graph", "the", "timeskew", "between", "the", "timestamps", "and", "real", "time", "for", "a", "given", "ip" ]
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet.py#L1036-L1051
phaethon/kamene
kamene/layers/inet.py
mtr
def mtr(target, dport=80, minttl=1, maxttl=30, stype="Random", srcport=50000, iface=None, l4=None, filter=None, timeout=2, verbose=None, gw=None, netproto="TCP", nquery=1, ptype=None, payload=b'', privaddr=0, rasn=1, **kargs): """A Multi-Traceroute (mtr) command: mtr(target, [maxttl=30,] [dport=80,] [sport...
python
def mtr(target, dport=80, minttl=1, maxttl=30, stype="Random", srcport=50000, iface=None, l4=None, filter=None, timeout=2, verbose=None, gw=None, netproto="TCP", nquery=1, ptype=None, payload=b'', privaddr=0, rasn=1, **kargs): """A Multi-Traceroute (mtr) command: mtr(target, [maxttl=30,] [dport=80,] [sport...
[ "def", "mtr", "(", "target", ",", "dport", "=", "80", ",", "minttl", "=", "1", ",", "maxttl", "=", "30", ",", "stype", "=", "\"Random\"", ",", "srcport", "=", "50000", ",", "iface", "=", "None", ",", "l4", "=", "None", ",", "filter", "=", "None",...
A Multi-Traceroute (mtr) command: mtr(target, [maxttl=30,] [dport=80,] [sport=80,] [minttl=1,] [maxttl=1,] [iface=None] [l4=None,] [filter=None,] [nquery=1,] [privaddr=0,] [rasn=1,] [verbose=conf.verb]) stype: Source Port Type: "Random" or "Increment". srcport: Source Po...
[ "A", "Multi", "-", "Traceroute", "(", "mtr", ")", "command", ":", "mtr", "(", "target", "[", "maxttl", "=", "30", "]", "[", "dport", "=", "80", "]", "[", "sport", "=", "80", "]", "[", "minttl", "=", "1", "]", "[", "maxttl", "=", "1", "]", "["...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet.py#L2565-L2866
phaethon/kamene
kamene/layers/inet.py
TracerouteResult.trace3D
def trace3D(self): """Give a 3D representation of the traceroute. right button: rotate the scene middle button: zoom left button: move the scene left button on a ball: toggle IP displaying ctrl-left button on a ball: scan ports 21,22,23,25,80 and 443 and display the resul...
python
def trace3D(self): """Give a 3D representation of the traceroute. right button: rotate the scene middle button: zoom left button: move the scene left button on a ball: toggle IP displaying ctrl-left button on a ball: scan ports 21,22,23,25,80 and 443 and display the resul...
[ "def", "trace3D", "(", "self", ")", ":", "trace", "=", "self", ".", "get_trace", "(", ")", "import", "visual", "class", "IPsphere", "(", "visual", ".", "sphere", ")", ":", "def", "__init__", "(", "self", ",", "ip", ",", "*", "*", "kargs", ")", ":",...
Give a 3D representation of the traceroute. right button: rotate the scene middle button: zoom left button: move the scene left button on a ball: toggle IP displaying ctrl-left button on a ball: scan ports 21,22,23,25,80 and 443 and display the result
[ "Give", "a", "3D", "representation", "of", "the", "traceroute", ".", "right", "button", ":", "rotate", "the", "scene", "middle", "button", ":", "zoom", "left", "button", ":", "move", "the", "scene", "left", "button", "on", "a", "ball", ":", "toggle", "IP...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet.py#L1094-L1203
phaethon/kamene
kamene/layers/inet.py
MTR.get_asns
def get_asns(self, privaddr=0): """Obtain associated AS Numbers for IPv4 Addreses. privaddr: 0 - Normal display of AS numbers, 1 - Do not show an associated AS Number bound box (cluster) on graph for a private IPv4 Address.""" ips = {} if privaddr: for...
python
def get_asns(self, privaddr=0): """Obtain associated AS Numbers for IPv4 Addreses. privaddr: 0 - Normal display of AS numbers, 1 - Do not show an associated AS Number bound box (cluster) on graph for a private IPv4 Address.""" ips = {} if privaddr: for...
[ "def", "get_asns", "(", "self", ",", "privaddr", "=", "0", ")", ":", "ips", "=", "{", "}", "if", "privaddr", ":", "for", "k", ",", "v", "in", "self", ".", "_ips", ".", "items", "(", ")", ":", "if", "not", "is_private_addr", "(", "k", ")", ":", ...
Obtain associated AS Numbers for IPv4 Addreses. privaddr: 0 - Normal display of AS numbers, 1 - Do not show an associated AS Number bound box (cluster) on graph for a private IPv4 Address.
[ "Obtain", "associated", "AS", "Numbers", "for", "IPv4", "Addreses", ".", "privaddr", ":", "0", "-", "Normal", "display", "of", "AS", "numbers", "1", "-", "Do", "not", "show", "an", "associated", "AS", "Number", "bound", "box", "(", "cluster", ")", "on", ...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet.py#L1567-L1611
phaethon/kamene
kamene/layers/inet.py
MTR.graph
def graph(self, ASres=None, padding=0, vspread=0.75, title="Multi-Traceroute Probe (MTR)", timestamp="", rtt=1, **kargs): """x.graph(ASres=conf.AS_resolver, other args): ASres = None : Use AS default resolver => 'conf.AS_resolver' ASres = AS_resolver() : default whois AS resolver (riswh...
python
def graph(self, ASres=None, padding=0, vspread=0.75, title="Multi-Traceroute Probe (MTR)", timestamp="", rtt=1, **kargs): """x.graph(ASres=conf.AS_resolver, other args): ASres = None : Use AS default resolver => 'conf.AS_resolver' ASres = AS_resolver() : default whois AS resolver (riswh...
[ "def", "graph", "(", "self", ",", "ASres", "=", "None", ",", "padding", "=", "0", ",", "vspread", "=", "0.75", ",", "title", "=", "\"Multi-Traceroute Probe (MTR)\"", ",", "timestamp", "=", "\"\"", ",", "rtt", "=", "1", ",", "*", "*", "kargs", ")", ":...
x.graph(ASres=conf.AS_resolver, other args): ASres = None : Use AS default resolver => 'conf.AS_resolver' ASres = AS_resolver() : default whois AS resolver (riswhois.ripe.net) ASres = AS_resolver_cymru(): use whois.cymru.com whois database ASres = AS_resolver(server="whois.ra.ne...
[ "x", ".", "graph", "(", "ASres", "=", "conf", ".", "AS_resolver", "other", "args", ")", ":", "ASres", "=", "None", ":", "Use", "AS", "default", "resolver", "=", ">", "conf", ".", "AS_resolver", "ASres", "=", "AS_resolver", "()", ":", "default", "whois"...
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet.py#L2348-L2370
twitterdev/search-tweets-python
setup.py
parse_version
def parse_version(str_): """ Parses the program's version from a python variable declaration. """ v = re.findall(r"\d+.\d+.\d+", str_) if v: return v[0] else: print("cannot parse string {}".format(str_)) raise KeyError
python
def parse_version(str_): """ Parses the program's version from a python variable declaration. """ v = re.findall(r"\d+.\d+.\d+", str_) if v: return v[0] else: print("cannot parse string {}".format(str_)) raise KeyError
[ "def", "parse_version", "(", "str_", ")", ":", "v", "=", "re", ".", "findall", "(", "r\"\\d+.\\d+.\\d+\"", ",", "str_", ")", "if", "v", ":", "return", "v", "[", "0", "]", "else", ":", "print", "(", "\"cannot parse string {}\"", ".", "format", "(", "str...
Parses the program's version from a python variable declaration.
[ "Parses", "the", "program", "s", "version", "from", "a", "python", "variable", "declaration", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/setup.py#L8-L17
twitterdev/search-tweets-python
searchtweets/result_stream.py
make_session
def make_session(username=None, password=None, bearer_token=None, extra_headers_dict=None): """Creates a Requests Session for use. Accepts a bearer token for premiums users and will override username and password information if present. Args: username (str): username for the session pa...
python
def make_session(username=None, password=None, bearer_token=None, extra_headers_dict=None): """Creates a Requests Session for use. Accepts a bearer token for premiums users and will override username and password information if present. Args: username (str): username for the session pa...
[ "def", "make_session", "(", "username", "=", "None", ",", "password", "=", "None", ",", "bearer_token", "=", "None", ",", "extra_headers_dict", "=", "None", ")", ":", "if", "password", "is", "None", "and", "bearer_token", "is", "None", ":", "logger", ".", ...
Creates a Requests Session for use. Accepts a bearer token for premiums users and will override username and password information if present. Args: username (str): username for the session password (str): password for the user bearer_token (str): token for a premium API user.
[ "Creates", "a", "Requests", "Session", "for", "use", ".", "Accepts", "a", "bearer", "token", "for", "premiums", "users", "and", "will", "override", "username", "and", "password", "information", "if", "present", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L31-L61
twitterdev/search-tweets-python
searchtweets/result_stream.py
retry
def retry(func): """ Decorator to handle API retries and exceptions. Defaults to three retries. Args: func (function): function for decoration Returns: decorated function """ def retried_func(*args, **kwargs): max_tries = 3 tries = 0 while True: ...
python
def retry(func): """ Decorator to handle API retries and exceptions. Defaults to three retries. Args: func (function): function for decoration Returns: decorated function """ def retried_func(*args, **kwargs): max_tries = 3 tries = 0 while True: ...
[ "def", "retry", "(", "func", ")", ":", "def", "retried_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "max_tries", "=", "3", "tries", "=", "0", "while", "True", ":", "try", ":", "resp", "=", "func", "(", "*", "args", ",", "*", "*",...
Decorator to handle API retries and exceptions. Defaults to three retries. Args: func (function): function for decoration Returns: decorated function
[ "Decorator", "to", "handle", "API", "retries", "and", "exceptions", ".", "Defaults", "to", "three", "retries", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L64-L108
twitterdev/search-tweets-python
searchtweets/result_stream.py
request
def request(session, url, rule_payload, **kwargs): """ Executes a request with the given payload and arguments. Args: session (requests.Session): the valid session object url (str): Valid API endpoint rule_payload (str or dict): rule package for the POST. If you pass a d...
python
def request(session, url, rule_payload, **kwargs): """ Executes a request with the given payload and arguments. Args: session (requests.Session): the valid session object url (str): Valid API endpoint rule_payload (str or dict): rule package for the POST. If you pass a d...
[ "def", "request", "(", "session", ",", "url", ",", "rule_payload", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "rule_payload", ",", "dict", ")", ":", "rule_payload", "=", "json", ".", "dumps", "(", "rule_payload", ")", "logger", ".", "d...
Executes a request with the given payload and arguments. Args: session (requests.Session): the valid session object url (str): Valid API endpoint rule_payload (str or dict): rule package for the POST. If you pass a dictionary, it will be converted into JSON.
[ "Executes", "a", "request", "with", "the", "given", "payload", "and", "arguments", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L112-L126
twitterdev/search-tweets-python
searchtweets/result_stream.py
collect_results
def collect_results(rule, max_results=500, result_stream_args=None): """ Utility function to quickly get a list of tweets from a ``ResultStream`` without keeping the object around. Requires your args to be configured prior to using. Args: rule (str): valid powertrack rule for your account, ...
python
def collect_results(rule, max_results=500, result_stream_args=None): """ Utility function to quickly get a list of tweets from a ``ResultStream`` without keeping the object around. Requires your args to be configured prior to using. Args: rule (str): valid powertrack rule for your account, ...
[ "def", "collect_results", "(", "rule", ",", "max_results", "=", "500", ",", "result_stream_args", "=", "None", ")", ":", "if", "result_stream_args", "is", "None", ":", "logger", ".", "error", "(", "\"This function requires a configuration dict for the \"", "\"inner Re...
Utility function to quickly get a list of tweets from a ``ResultStream`` without keeping the object around. Requires your args to be configured prior to using. Args: rule (str): valid powertrack rule for your account, preferably generated by the `gen_rule_payload` function. max_resu...
[ "Utility", "function", "to", "quickly", "get", "a", "list", "of", "tweets", "from", "a", "ResultStream", "without", "keeping", "the", "object", "around", ".", "Requires", "your", "args", "to", "be", "configured", "prior", "to", "using", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L276-L308
twitterdev/search-tweets-python
searchtweets/result_stream.py
ResultStream.stream
def stream(self): """ Main entry point for the data from the API. Will automatically paginate through the results via the ``next`` token and return up to ``max_results`` tweets or up to ``max_requests`` API calls, whichever is lower. Usage: >>> result_stream = Result...
python
def stream(self): """ Main entry point for the data from the API. Will automatically paginate through the results via the ``next`` token and return up to ``max_results`` tweets or up to ``max_requests`` API calls, whichever is lower. Usage: >>> result_stream = Result...
[ "def", "stream", "(", "self", ")", ":", "self", ".", "init_session", "(", ")", "self", ".", "check_counts", "(", ")", "self", ".", "execute_request", "(", ")", "self", ".", "stream_started", "=", "True", "while", "True", ":", "for", "tweet", "in", "sel...
Main entry point for the data from the API. Will automatically paginate through the results via the ``next`` token and return up to ``max_results`` tweets or up to ``max_requests`` API calls, whichever is lower. Usage: >>> result_stream = ResultStream(**kwargs) >>> strea...
[ "Main", "entry", "point", "for", "the", "data", "from", "the", "API", ".", "Will", "automatically", "paginate", "through", "the", "results", "via", "the", "next", "token", "and", "return", "up", "to", "max_results", "tweets", "or", "up", "to", "max_requests"...
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L193-L227
twitterdev/search-tweets-python
searchtweets/result_stream.py
ResultStream.init_session
def init_session(self): """ Defines a session object for passing requests. """ if self.session: self.session.close() self.session = make_session(self.username, self.password, self.bearer_token, ...
python
def init_session(self): """ Defines a session object for passing requests. """ if self.session: self.session.close() self.session = make_session(self.username, self.password, self.bearer_token, ...
[ "def", "init_session", "(", "self", ")", ":", "if", "self", ".", "session", ":", "self", ".", "session", ".", "close", "(", ")", "self", ".", "session", "=", "make_session", "(", "self", ".", "username", ",", "self", ".", "password", ",", "self", "."...
Defines a session object for passing requests.
[ "Defines", "a", "session", "object", "for", "passing", "requests", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L229-L238
twitterdev/search-tweets-python
searchtweets/result_stream.py
ResultStream.check_counts
def check_counts(self): """ Disables tweet parsing if the count API is used. """ if "counts" in re.split("[/.]", self.endpoint): logger.info("disabling tweet parsing due to counts API usage") self._tweet_func = lambda x: x
python
def check_counts(self): """ Disables tweet parsing if the count API is used. """ if "counts" in re.split("[/.]", self.endpoint): logger.info("disabling tweet parsing due to counts API usage") self._tweet_func = lambda x: x
[ "def", "check_counts", "(", "self", ")", ":", "if", "\"counts\"", "in", "re", ".", "split", "(", "\"[/.]\"", ",", "self", ".", "endpoint", ")", ":", "logger", ".", "info", "(", "\"disabling tweet parsing due to counts API usage\"", ")", "self", ".", "_tweet_fu...
Disables tweet parsing if the count API is used.
[ "Disables", "tweet", "parsing", "if", "the", "count", "API", "is", "used", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L240-L246
twitterdev/search-tweets-python
searchtweets/result_stream.py
ResultStream.execute_request
def execute_request(self): """ Sends the request to the API and parses the json response. Makes some assumptions about the session length and sets the presence of a "next" token. """ if self.n_requests % 20 == 0 and self.n_requests > 1: logger.info("refreshing...
python
def execute_request(self): """ Sends the request to the API and parses the json response. Makes some assumptions about the session length and sets the presence of a "next" token. """ if self.n_requests % 20 == 0 and self.n_requests > 1: logger.info("refreshing...
[ "def", "execute_request", "(", "self", ")", ":", "if", "self", ".", "n_requests", "%", "20", "==", "0", "and", "self", ".", "n_requests", ">", "1", ":", "logger", ".", "info", "(", "\"refreshing session\"", ")", "self", ".", "init_session", "(", ")", "...
Sends the request to the API and parses the json response. Makes some assumptions about the session length and sets the presence of a "next" token.
[ "Sends", "the", "request", "to", "the", "API", "and", "parses", "the", "json", "response", ".", "Makes", "some", "assumptions", "about", "the", "session", "length", "and", "sets", "the", "presence", "of", "a", "next", "token", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L248-L265
twitterdev/search-tweets-python
searchtweets/api_utils.py
convert_utc_time
def convert_utc_time(datetime_str): """ Handles datetime argument conversion to the GNIP API format, which is `YYYYMMDDHHSS`. Flexible passing of date formats in the following types:: - YYYYmmDDHHMM - YYYY-mm-DD - YYYY-mm-DD HH:MM - YYYY-mm-DDTHH:MM Args: dateti...
python
def convert_utc_time(datetime_str): """ Handles datetime argument conversion to the GNIP API format, which is `YYYYMMDDHHSS`. Flexible passing of date formats in the following types:: - YYYYmmDDHHMM - YYYY-mm-DD - YYYY-mm-DD HH:MM - YYYY-mm-DDTHH:MM Args: dateti...
[ "def", "convert_utc_time", "(", "datetime_str", ")", ":", "if", "not", "datetime_str", ":", "return", "None", "if", "not", "set", "(", "[", "'-'", ",", "':'", "]", ")", "&", "set", "(", "datetime_str", ")", ":", "_date", "=", "datetime", ".", "datetime...
Handles datetime argument conversion to the GNIP API format, which is `YYYYMMDDHHSS`. Flexible passing of date formats in the following types:: - YYYYmmDDHHMM - YYYY-mm-DD - YYYY-mm-DD HH:MM - YYYY-mm-DDTHH:MM Args: datetime_str (str): valid formats are listed above. ...
[ "Handles", "datetime", "argument", "conversion", "to", "the", "GNIP", "API", "format", "which", "is", "YYYYMMDDHHSS", ".", "Flexible", "passing", "of", "date", "formats", "in", "the", "following", "types", "::" ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/api_utils.py#L24-L63
twitterdev/search-tweets-python
searchtweets/api_utils.py
change_to_count_endpoint
def change_to_count_endpoint(endpoint): """Utility function to change a normal endpoint to a ``count`` api endpoint. Returns the same endpoint if it's already a valid count endpoint. Args: endpoint (str): your api endpoint Returns: str: the modified endpoint for a count endpoint. ""...
python
def change_to_count_endpoint(endpoint): """Utility function to change a normal endpoint to a ``count`` api endpoint. Returns the same endpoint if it's already a valid count endpoint. Args: endpoint (str): your api endpoint Returns: str: the modified endpoint for a count endpoint. ""...
[ "def", "change_to_count_endpoint", "(", "endpoint", ")", ":", "tokens", "=", "filter", "(", "lambda", "x", ":", "x", "!=", "''", ",", "re", ".", "split", "(", "\"[/:]\"", ",", "endpoint", ")", ")", "filt_tokens", "=", "list", "(", "filter", "(", "lambd...
Utility function to change a normal endpoint to a ``count`` api endpoint. Returns the same endpoint if it's already a valid count endpoint. Args: endpoint (str): your api endpoint Returns: str: the modified endpoint for a count endpoint.
[ "Utility", "function", "to", "change", "a", "normal", "endpoint", "to", "a", "count", "api", "endpoint", ".", "Returns", "the", "same", "endpoint", "if", "it", "s", "already", "a", "valid", "count", "endpoint", ".", "Args", ":", "endpoint", "(", "str", "...
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/api_utils.py#L66-L83
twitterdev/search-tweets-python
searchtweets/api_utils.py
gen_rule_payload
def gen_rule_payload(pt_rule, results_per_call=None, from_date=None, to_date=None, count_bucket=None, tag=None, stringify=True): """ Generates the dict or json payload for a PowerTrack rule. Args: pt_rule (str): The string version of a...
python
def gen_rule_payload(pt_rule, results_per_call=None, from_date=None, to_date=None, count_bucket=None, tag=None, stringify=True): """ Generates the dict or json payload for a PowerTrack rule. Args: pt_rule (str): The string version of a...
[ "def", "gen_rule_payload", "(", "pt_rule", ",", "results_per_call", "=", "None", ",", "from_date", "=", "None", ",", "to_date", "=", "None", ",", "count_bucket", "=", "None", ",", "tag", "=", "None", ",", "stringify", "=", "True", ")", ":", "pt_rule", "=...
Generates the dict or json payload for a PowerTrack rule. Args: pt_rule (str): The string version of a powertrack rule, e.g., "beyonce has:geo". Accepts multi-line strings for ease of entry. results_per_call (int): number of tweets or counts returned per API call. Th...
[ "Generates", "the", "dict", "or", "json", "payload", "for", "a", "PowerTrack", "rule", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/api_utils.py#L86-L138
twitterdev/search-tweets-python
searchtweets/api_utils.py
gen_params_from_config
def gen_params_from_config(config_dict): """ Generates parameters for a ResultStream from a dictionary. """ if config_dict.get("count_bucket"): logger.warning("change your endpoint to the count endpoint; this is " "default behavior when the count bucket " ...
python
def gen_params_from_config(config_dict): """ Generates parameters for a ResultStream from a dictionary. """ if config_dict.get("count_bucket"): logger.warning("change your endpoint to the count endpoint; this is " "default behavior when the count bucket " ...
[ "def", "gen_params_from_config", "(", "config_dict", ")", ":", "if", "config_dict", ".", "get", "(", "\"count_bucket\"", ")", ":", "logger", ".", "warning", "(", "\"change your endpoint to the count endpoint; this is \"", "\"default behavior when the count bucket \"", "\"fiel...
Generates parameters for a ResultStream from a dictionary.
[ "Generates", "parameters", "for", "a", "ResultStream", "from", "a", "dictionary", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/api_utils.py#L141-L179
twitterdev/search-tweets-python
searchtweets/api_utils.py
infer_endpoint
def infer_endpoint(rule_payload): """ Infer which endpoint should be used for a given rule payload. """ bucket = (rule_payload if isinstance(rule_payload, dict) else json.loads(rule_payload)).get("bucket") return "counts" if bucket else "search"
python
def infer_endpoint(rule_payload): """ Infer which endpoint should be used for a given rule payload. """ bucket = (rule_payload if isinstance(rule_payload, dict) else json.loads(rule_payload)).get("bucket") return "counts" if bucket else "search"
[ "def", "infer_endpoint", "(", "rule_payload", ")", ":", "bucket", "=", "(", "rule_payload", "if", "isinstance", "(", "rule_payload", ",", "dict", ")", "else", "json", ".", "loads", "(", "rule_payload", ")", ")", ".", "get", "(", "\"bucket\"", ")", "return"...
Infer which endpoint should be used for a given rule payload.
[ "Infer", "which", "endpoint", "should", "be", "used", "for", "a", "given", "rule", "payload", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/api_utils.py#L182-L188
twitterdev/search-tweets-python
searchtweets/api_utils.py
validate_count_api
def validate_count_api(rule_payload, endpoint): """ Ensures that the counts api is set correctly in a payload. """ rule = (rule_payload if isinstance(rule_payload, dict) else json.loads(rule_payload)) bucket = rule.get('bucket') counts = set(endpoint.split("/")) & {"counts.json"} ...
python
def validate_count_api(rule_payload, endpoint): """ Ensures that the counts api is set correctly in a payload. """ rule = (rule_payload if isinstance(rule_payload, dict) else json.loads(rule_payload)) bucket = rule.get('bucket') counts = set(endpoint.split("/")) & {"counts.json"} ...
[ "def", "validate_count_api", "(", "rule_payload", ",", "endpoint", ")", ":", "rule", "=", "(", "rule_payload", "if", "isinstance", "(", "rule_payload", ",", "dict", ")", "else", "json", ".", "loads", "(", "rule_payload", ")", ")", "bucket", "=", "rule", "....
Ensures that the counts api is set correctly in a payload.
[ "Ensures", "that", "the", "counts", "api", "is", "set", "correctly", "in", "a", "payload", "." ]
train
https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/api_utils.py#L191-L205