Send sms using kannel & smmpsim - docker

I'm trying to send sms using kannel & smppsim.
I use docker as container.
I use this kannel.conf:
group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
admin-allow-ip = "127.0.0.1;192.168.59.103"
box-allow-ip = "127.0.0.1;192.168.59.103"
group = smsc
smsc = smpp
smsc-id = SMPPSim
host = 192.168.59.103
port = 2775
transceiver-mode = 1
smsc-username = smppclient1
smsc-password = password
system-type = 'VMA'
#service-type = 'test'
interface-version = 34
#system-id = smppclient
preferred-smsc-id = SMPPSim
connect-allow-ip = 192.168.59.103
group = smsbox
bearerbox-host = bearerbox
sendsms-port = 13013
global-sender = 13013
group = sendsms-user
username = tester
password = foobar
group = sms-service
keyword = default
text = "No service specified"
when sending a request to send sms I get "0: Accepted for delivery"
I'm seeing these errors in smsbox log:
2015-03-21 20:20:52 [1] [3] DEBUG: Status: 202 Answer: <Sent.>
2015-03-21 20:20:52 [1] [3] DEBUG: Delayed reply - wait for bearerbox
2015-03-21 20:20:52 [1] [0] DEBUG: Got ACK (0) of 74f9cefe-db95-4b7d-aa99-f07395d32915
2015-03-21 20:20:52 [1] [0] DEBUG: HTTP: Resetting HTTPClient for `192.168.59.3'.
2015-03-21 20:20:52 [1] [1] ERROR: Error reading from fd 24:
2015-03-21 20:20:52 [1] [1] ERROR: System error 104: Connection reset by peer
2015-03-21 20:20:52 [1] [1] DEBUG: HTTP: Destroying HTTPClient area 0x7fe8d0000ad0.
Bearbox doesn't present any errors and seem to pass the message to smppsim, smppsim shows this in log:
21 Assessing state of 1 messages in the OutboundQueue
21 Message:2 state=DELIVERED
The sms is not sent, what could be wrong?

I think its a problem with your Kannel configuration file, specially with smsbox and later parts. I used following as smsbox
group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013
global-sender = your sim number which you use in USB modem
sendsms-chars = "0123456789 +-"
log-file = "/var/log/kannel/smsbox.log"
log-level = 0
access-log = "/var/log/kannel/access.log"
and you can get my full configuration file from here. This worked fine for me.

This might be a problem of lоѕѕ оf thе соnnесtіоn оn thе rеmоtе ѕосkеt due tо а tіmеоut.
And SMPPSim is just a testing tool for kannel. It won't really send a message to your or mentioned mobile number. To send real messages you need to add either gsm modems or SMS operator details.
You can refer to userGuide from kannel.org.
To check your kannel status simply go to http://localhost:13000/status?password=password(password of your kannel)

Related

Offlineimap stops retrieving after first 20-30 messages

I have been trying to set up offlineimap to sync mail from gmail to the local folders on my mac machine.
The issue with my current set-up is that, offlineimap will start to sync the mail from both accounts, I can see lines like -
Copy message 3 (3 of 10966) repo1_remote:[Gmail]/Important -> repo1_local
But, after around 20-30 copy message, these lines just stop. Offlineimap is still connected though, it refreshes after 10 minutes and syncs again but, I cant see any more copy message lines in the repos any longer, it just stops. I can see these new 20-30 new messages in mutt, but not more. Killing and restarting offlineimap agains copies 20-30 new messages and again stops. I have no clue as to what is wrong. I guess it should copy all messages locally. Here is my offlineimaprc. I have the python file set up correctly.
[general]
metadata = ~/.offlineimap
accounts = repo1, repo2
maxsyncaccounts = 10
#ui = blinkenlights
ui = ttyui
pythonfile = ~/Development/OfflineIMAP/mail/offlineimap.py
#socktimeout = 60
[mbnames]
[Account repo2]
localrepository = repo2_local
remoterepository = repo2_remote
autorefresh = 10
status_backend = sqlite
synclabels = yes
[Account repo1]
localrepository = repo1_local
remoterepository = repo1_remote
autorefresh = 10
status_backend = sqlite
synclabels = yes
[Repository repo2_local]
type = GmailMaildir
nametrans = get_remote_name
localfolders = ~/Development/OfflineIMAP/mail/repo2
sep = /
restoreatime = yes
[Repository repo1_local]
type = GmailMaildir
nametrans = get_remote_name
localfolders = ~/Development/OfflineIMAP/mail/repo1
sep = /
restoreatime = yes
[Repository repo2_remote]
type = Gmail
folderfilter = is_included
nametrans = get_local_name
cert_fingerprint = 3ffdb8519c1c8242ce8387d3d9fccc208a776b4a
remoteuser = asd#gmail.com
remotepasseval = get_password('asd')
usecompression = yes
maxconnections = 3
[Repository repo1_remote]
type = Gmail
folderfilter = is_included
nametrans = get_local_name
cert_fingerprint = 3ffdb8519c1c8242ce8387d3d9fccc208a776b4a
remoteuser = qwe#gmail.com
remotepasseval = get_password('qwe')
usecompression = yes
maxconnections = 3
I would like to know what is preventing offlineimap from copying further messages and what should I change in the config to make it work properly.
I've just recently ran into the same problem with gmail. In my case disabling compression and setting connections limit to 1 resolved the issue (didn't have time to investigate fully). Have you tried doing this?

FedEx error: Special service invalid 8200

I'm trying to connect to FedEx International WebServices API for Ship Service.
I'm using WSDL of v13.
Below is my SOAP Content:
<ns:ProcessShipmentRequest xmlns:ns="http://fedex.com/ws/ship/v13">
<ns:WebAuthenticationDetail>
<ns:UserCredential>
<ns:Key>GHmnVXAyWqWUemqD</ns:Key>
<ns:Password>1VYHs6O1vhKA3xPVAExhx1vUB</ns:Password>
</ns:UserCredential>
</ns:WebAuthenticationDetail>
<ns:ClientDetail>
<ns:AccountNumber>510087666</ns:AccountNumber>
<ns:MeterNumber>100115929</ns:MeterNumber>
</ns:ClientDetail>
<ns:Version>
<ns:ServiceId>ship</ns:ServiceId>
<ns:Major>13</ns:Major>
<ns:Intermediate>0</ns:Intermediate>
<ns:Minor>0</ns:Minor>
</ns:Version>
<ns:RequestedShipment>
<ns:ShipTimestamp>2015-04-17T12:51:03.404660Z</ns:ShipTimestamp>
<ns:DropoffType>REGULAR_PICKUP</ns:DropoffType>
<ns:ServiceType>INTERNATIONAL_PRIORITY</ns:ServiceType>
<ns:PackagingType>FEDEX_25KG_BOX</ns:PackagingType>
<ns:TotalWeight>
<ns:Units>LB</ns:Units>
<ns:Value>40.0</ns:Value>
</ns:TotalWeight>
<ns:Shipper>
<ns:Contact>
<ns:CompanyName>Your Company</ns:CompanyName>
<ns:PhoneNumber>4354454365746</ns:PhoneNumber>
</ns:Contact>
<ns:Address>
<ns:StreetLines>3121 W Government Way</ns:StreetLines>
<ns:StreetLines>Seattle</ns:StreetLines>
<ns:City>Seattle</ns:City>
<ns:StateOrProvinceCode>WA</ns:StateOrProvinceCode>
<ns:PostalCode>98199</ns:PostalCode>
<ns:CountryCode>US</ns:CountryCode>
<ns:CountryName>United States</ns:CountryName>
<ns:Residential>false</ns:Residential>
</ns:Address>
</ns:Shipper>
<ns:Recipient>
<ns:Contact>
<ns:PersonName>Agrolait</ns:PersonName>
<ns:PhoneNumber>3210588558</ns:PhoneNumber>
</ns:Contact>
<ns:Address>
<ns:StreetLines>1010 EASY ST</ns:StreetLines>
<ns:StreetLines>Apt# 11</ns:StreetLines>
<ns:City>OTTAWA</ns:City>
<ns:StateOrProvinceCode>ON</ns:StateOrProvinceCode>
<ns:PostalCode>K1A0B1</ns:PostalCode>
<ns:CountryCode>CA</ns:CountryCode>
<ns:Residential>false</ns:Residential>
</ns:Address>
</ns:Recipient>
<ns:ShippingChargesPayment>
<ns:PaymentType>SENDER</ns:PaymentType>
<ns:Payor>
<ns:ResponsibleParty>
<ns:AccountNumber>510087666</ns:AccountNumber>
<ns:Contact>
<ns:PersonName>Your Company</ns:PersonName>
<ns:CompanyName>Your Company</ns:CompanyName>
<ns:PhoneNumber>4354454365746</ns:PhoneNumber>
</ns:Contact>
<ns:Address>
<ns:CountryCode>US</ns:CountryCode>
</ns:Address>
</ns:ResponsibleParty>
</ns:Payor>
</ns:ShippingChargesPayment>
<ns:CustomsClearanceDetail>
<ns:ClearanceBrokerage>BROKER_UNASSIGNED</ns:ClearanceBrokerage>
<ns:DutiesPayment>
<ns:PaymentType>SENDER</ns:PaymentType>
<ns:Payor>
<ns:ResponsibleParty>
<ns:AccountNumber>510087666</ns:AccountNumber>
<ns:Contact>
<ns:PersonName>Your Company</ns:PersonName>
<ns:CompanyName>Your Company</ns:CompanyName>
<ns:PhoneNumber>4354454365746</ns:PhoneNumber>
</ns:Contact>
</ns:ResponsibleParty>
</ns:Payor>
</ns:DutiesPayment>
<ns:DocumentContent>NON_DOCUMENTS</ns:DocumentContent>
<ns:CustomsValue>
<ns:Currency>USD</ns:Currency>
<ns:Amount>100.0</ns:Amount>
</ns:CustomsValue>
<ns:FreightOnValue>OWN_RISK</ns:FreightOnValue>
<ns:CommercialInvoice>
<ns:TaxesOrMiscellaneousChargeType>TAXES</ns:TaxesOrMiscellaneousChargeType>
<ns:Purpose>SOLD</ns:Purpose>
<ns:TermsOfSale>FOB_OR_FCA</ns:TermsOfSale>
</ns:CommercialInvoice>
<ns:Commodities>
<ns:NumberOfPieces>1</ns:NumberOfPieces>
<ns:Description>[CARD] Graphics Card</ns:Description>
<ns:CountryOfManufacture>US</ns:CountryOfManufacture>
<ns:Weight>
<ns:Units>LB</ns:Units>
<ns:Value>10.0</ns:Value>
</ns:Weight>
<ns:Quantity>1</ns:Quantity>
<ns:QuantityUnits>Unit(s)</ns:QuantityUnits>
<ns:UnitPrice>
<ns:Currency>USD</ns:Currency>
<ns:Amount>100.0</ns:Amount>
</ns:UnitPrice>
<ns:CustomsValue>
<ns:Currency>USD</ns:Currency>
<ns:Amount>100.0</ns:Amount>
</ns:CustomsValue>
</ns:Commodities>
</ns:CustomsClearanceDetail>
<ns:LabelSpecification>
<ns:LabelFormatType>COMMON2D</ns:LabelFormatType>
<ns:ImageType>PNG</ns:ImageType>
<ns:LabelStockType>PAPER_4X6</ns:LabelStockType>
<ns:LabelPrintingOrientation>BOTTOM_EDGE_OF_TEXT_FIRST</ns:LabelPrintingOrientation>
</ns:LabelSpecification>
<ns:ShippingDocumentSpecification>
<ns:ShippingDocumentTypes>CERTIFICATE_OF_ORIGIN</ns:ShippingDocumentTypes>
</ns:ShippingDocumentSpecification>
<ns:RateRequestTypes>ACCOUNT</ns:RateRequestTypes>
<ns:EdtRequestType>ALL</ns:EdtRequestType>
<ns:PackageCount>1</ns:PackageCount>
<ns:RequestedPackageLineItems>
<ns:SequenceNumber>1</ns:SequenceNumber>
<ns:Weight>
<ns:Units>LB</ns:Units>
<ns:Value>40.0</ns:Value>
</ns:Weight>
<ns:Dimensions>
<ns:Length>17</ns:Length>
<ns:Width>12</ns:Width>
<ns:Height>3</ns:Height>
<ns:Units>IN</ns:Units>
</ns:Dimensions>
<ns:PhysicalPackaging>BOX</ns:PhysicalPackaging>
</ns:RequestedPackageLineItems>
</ns:RequestedShipment>
</ns:ProcessShipmentRequest>
When I send the request I get Below Response:
(reply){
HighestSeverity = "ERROR"
Notifications[] =
(Notification){
Severity = "ERROR"
Source = "ship"
Code = "8200"
Message = "Special service is invalid."
LocalizedMessage = "Special service is invalid."
},
(Notification){
Severity = "WARNING"
Source = "ship"
Code = "7037"
Message = "Harmonized code is missing or invalid for commodity (COMMODITY_INDEX}; estimated duties and taxes were not returned."
LocalizedMessage = "Harmonized code is missing or invalid for commodity (COMMODITY_INDEX}; estimated duties and taxes were not returned."
MessageParameters[] =
(NotificationParameter){
Id = "COMMODITY_INDEX"
Value = "1"
},
},
Version =
(VersionId){
ServiceId = "ship"
Major = 13
Intermediate = 0
Minor = 0
}
}
Warning I can have fixed but the Special Service Invalid Error Persists. Please let me know If I'm passing some wrong value or if I'm missing some Value.
Note: I tried adding the special services like COD, but the issue is same.
Since you don't have a special service defined, this error is really odd. You need to email websupport at fedex dot com for resolution. FedEx error responses are terrible.

scapy dns sniff with additional records

i have python/scapy sniffer for DNS.
I am able to sniff DNS messages and get IP/UDP source and destination IP address and ports as well as DNS but I have problems parsing and getting additional answers and additional records if there is more then one.
from scapy i see DNS data i can get but do not know how to get additional records with ls(DNS),ls(DNSQR) and ls(DNSRR)
I would appreciate some help or solution to work this out.
My python/scapy script is below
#!/usr/bin/env python
from scapy.all import *
from datetime import datetime
import time
import datetime
import sys
############# MODIFY THIS PART IF NECESSARY ###############
interface = 'eth0'
filter_bpf = 'udp and port 53'
# ------ SELECT/FILTER MSGS
def select_DNS(pkt):
pkt_time = pkt.sprintf('%sent.time%')
# ------ SELECT/FILTER DNS MSGS
try:
if DNSQR in pkt and pkt.dport == 53:
# queries
print '[**] Detected DNS Message at: ' + pkt_time
p_id = pkt[DNS].id
cli_ip = pkt[IP].src
cli_port = pkt.sport
srv_ip = pkt[IP].dst
srv_port = pkt.dport
query = pkt[DNSQR].qname
q_class = pkt[DNSQR].qclass
qr_class = pkt[DNSQR].sprintf('%qclass%')
type = pkt[DNSQR].sprintf('%qtype%')
#
elif DNSRR in pkt and pkt.sport == 53:
# responses
pkt_time = pkt.sprintf('%sent.time%')
p_id = pkt[DNS].id
srv_ip = pkt[IP].src
srv_port = pkt.sport
cli_ip = pkt[IP].dst
cli_port = pkt.dport
response = pkt[DNSRR].rdata
r_class = pkt[DNSRR].rclass
rr_class = pkt[DNSRR].sprintf("%rclass%")
type = pkt[DNSRR].sprintf("%type%")
ttl = pkt[DNSRR].ttl
len = pkt[DNSRR].rdlen
#
print response
except:
pass
# ------ START SNIFFER
sniff(iface=interface, filter=filter_bpf, store=0, prn=select_DNS)

Graphite carbon-relay not working

I have two graphite setup and I am trying to relay the traffic between the two, but somehow the carbon-relay is not working.
My cache runs on 2003/2004 and relay on 2013/2014
Following are the configurations done :
#carbon file
[cache:b]
LINE_RECEIVER_PORT = 2003
PICKLE_RECEIVER_PORT = 2004
CACHE_QUERY_PORT = 7012
[relay]
LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_PORT = 2013
PICKLE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_PORT = 2014
RELAY_METHOD = rules
REPLICATION_FACTOR = 1
DESTINATIONS = 127.0.0.1:2003:a, aa.bb.cc.dd:2003:b
#relay-rules file
[default]
default = true
destinations = 127.0.0.1:2003:a, aa.bb.cc.dd:2003:b
Any pointers will be helpful
As part of the recent project at work, I've figured out that carbon demons uses PICKLE protocol when sending data to the destinations.
So the destination of carbon-relay should be carbon-cache's pickle receiver port instead.
#carbon.conf
....
[relay]
LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_PORT = 2013
PICKLE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_PORT = 2014
RELAY_METHOD = rules
REPLICATION_FACTOR = 1
DESTINATIONS = 127.0.0.1:2004:a, aa.bb.cc.dd:2004:b
Also modify the relay-rules.conf with the same destinations specified in carbon.conf
relay-rules.conf
.....
[default]
default = true
destinations = 127.0.0.1:2004:a, aa.bb.cc.dd:2004:b

Wireshark does not get Scapy Modbus response

I'm running the code example below against a remote PLC with Wireshark running. Why do I only get the query (I should get the response too)? It seems that the PLC sends the response, since the output of Scapy says Received 1 packets, got 1 answers, remaining 0 packets.
Any ideas of why is this happening?
I also performed the sniffing using the sniff() function from Scapy but the result is the same (only get the query).
#! /usr/bin/env python
import logging
logging.getLogger("scapy").setLevel(1)
from scapy import *
from modLib import *
# IP for all transmissions
ip = IP(dst="192.168.10.131")
# Sets up the session with a TCP three-way handshake
# Send the syn, receive the syn/ack
tcp = TCP( flags = 'S', window = 65535, sport = RandShort(), dport = 502, options = [('MSS', 1360 ), ('NOP', 1), ('NOP', 1), ('SAckOK', '')])
synAck = sr1 ( ip / tcp )
# Send the ack
tcp.flags = 'A'
tcp.sport = synAck[TCP].dport
tcp.seq = synAck[TCP].ack
tcp.ack = synAck[TCP].seq + 1
tcp.options = ''
send( ip / tcp )
# Creates and sends the Modbus Read Holding Registers command packet
# Send the ack/push i.e. the request, receive the data i.e. the response
tcp.flags = 'AP'
adu = ModbusADU()
pdu = ModbusPDU03()
adu = adu / pdu
tcp = tcp / adu
data = sr1(( ip / tcp ), timeout = 2)
data.show()
# Acknowledges the response
# Ack the data response
# TODO: note, the 17 below should be replaced with a read packet length method...
tcp.flags = 'A'
tcp.seq = data[TCP].ack
tcp.ack = data[TCP] + 17
tcp.payload = ''
finAck = sr1( ip / tcp )
First, you have a bug in your code (which is present in the original version http://www.digitalbond.com/scadapedia/security-controls/scapy-modbus-extensions/), you need to add .seq there: tcp.ack = data[TCP].seq + 17.
As said in the comment, you could write tcp.ack = data[TCP].seq + len(data[TCP].payload).
Anyway it's generally useless to do the TCP stack's work for the kind of things you try to do.
I would do something like that:
from scapy import *
from modLib import *
import socket
sock = socket.socket()
sock.connect(("192.168.10.131", 502))
s = StreamSocket(sock, basecls=ModbusADU)
ans, unans = s.sr(ModbusADU()/ModbusPDU03())
ans.show()
Does this work better?

Resources