i'm new to ZKteco devices! I am using a Zkteco device. I have a Zkteco Device and I have downloaded a standalone SDK, but this SDK doesn't trigger the events, (for example OnVerify, or OnAttTransaction).
So, I read in some articles, that I need to use Push SDk, but I can't find it.
I took one month to find that for that PUSH SDK and ADMS, clearly ZKTeco is not open to share that. so I had try to proceed otherwise. Here is the solution I had implement and it work properly.
The push SDK is just HTTP request made by ZKTeco device to the Bioserver.
You can use a tool like Wireshark to scan HTTP requests made by your device and implement same request/response on your own server.
For exemple, the ZKTeco device model MB560-VL send requests like this one
GET http://[SERVER-IP:PORT]/iclock/getrequest?SN=XXXXXXXXXX
and if like the BioTime software, your server just send
OK
as response in text/plain, your device will view your server as a "BioTime"
Note that your ZkTeco Device should have ADMS support, so that you will first configure SERVER-IP and PORT on the device (see your official device documentation on ZKTeco website)
User registration
When a user is registered on the device, the device send this request
POST /iclock/cdata?SN=XXXXXXXXXX&table=OPERLOG&Stamp=9999
with user information on the HTTP buffer. something like this one
PIN=2\tName=Johny Deep\tPri=0\tPasswd=\tCard=\tGrp=1\tTZ=0000000100000000\tVerify=0\tViceCard=\tStartDatetime=0\tEndDatetime=0\n
your server should just parse this data and respond OK to this request
User logs (clock_in / clock_out) Device request
POST /iclock/cdata?SN=XXXXXXXXXX&table=ATTLOG&Stamp=9999
the data sent by device on HTTP data buffer looks like
2\t2022-07-12 16:00:20\t1\t15\t\t0\t0\t\t\t43\n
As you can see you parse this string with '\t' as the separator of informations
the first integer is the User-PIN,
the second part is the date and time,
the third part is clock-in if value==0 and clock-out if value==1
Here is an exemple of implementation with Python
#http.route('/iclock/getrequest', type='http', auth="public", csrf=False)
def zk_bio_device_ping(request):
print("----------DEVICE PING-----------")
print(request.GET)
return HttpResponse("OK", content_type='text/plain')
#http.route('/iclock/getrequest', type='http', auth="public", csrf=False)
def zk_bio_device_push(request):
print("----------DEVICE SEND DATA----------")
print(request.GET)
print(request.body.decode('utf-8'))
return HttpResponse("OK", content_type='text/plain')
Device do not use any authentification to communicate with server ! I'm pretty sure that's a big security issue.
Related
I've built a web api that is called via an application (iOS/Android) through HTTP requests. I'm trying to implement a GET request that returns different data based on the device, OS, application version, .. etc. I've been using UserAgent with IOS devices and it's working just fine, it goes like that:
var uaParser = Parser.GetDefault();
var clientInfo = uaParser.Parse(Request.Headers.UserAgent.ToString());
Also if I opened the request via browser it also returns the data. Example of the response is: UserAgent: Windows 10 Other Chrome 63.0.3239
The problem is in the Android devices, it doesn't send any data about neither the device nor the OS, and I don't want to hard code the details in the android apps, I believe they are sent somewhere as Crashlytics can show these details for both iOS and Android.
Is there is any possible solution to get this data from the requests itself?
If you really wana do that then you could programically get android device name and its version and send it to your server as a parameter in http request...
To get Device Name
String devName = android.os.Build.MODEL;
To get Version code
String androidOS = Build.VERSION.RELEASE;
Then You Could Easily Send Them To Your Server As A Parameter In Your Request And Store Them To Database etc....Hope This Helps ! Cheers !
currently I'm working on an Android App for sending and receiving VoIP Calls and we are using the Android.Net.Sip Package to register at our SIP Server.
Now we are wondering if there is a way to modify the Contact header in the register package which is sent as an request to our SIP Server.
This is an example SIP Package:
REGISTER sip:example.com SIP/2.0
Via: SIP/2.0/UDP pc34.example.com;branch=z9hG4bKnaaff
From: sip:joe#example.com;tag=99a8s
To: sip:joe#example.com
Call-ID: 88askjda9#pc34.example.com
CSeq: 9976 REGISTER
Contact: sip:joe#pc34.example.com
And we need to change the Contact header, so our SIP Server knows where to send a push notification if the target user is not registered at the moment.
From reading the Android.Net.Sip code, I found out that the ContactHeader is generated using the UserName, Domain, Transport protocol and the DisplayName. When I am setting the DisplayName to some sample string, it however does not get into the ContactHeader.
We are using Xamarin.Android.
Hoping for some useful solutions on this.
Sincerly,
I want to get notifications when a new feed has landed on a designated page (by page id). After what I understand, the Realtime-update og Graph API should be able to do this trick according to https://developers.facebook.com/docs/graph-api/real-time-updates/v2.4.
So I want to add a new subscription, which I try to do with the following code:
dynamic result = client.Post(urlPath, new
{
#object = "page",
callback_url = callbackUrl,
fields = "feed",
verify_token = "654321",
access_token = accessToken
});
return result;
But when I try to run this, I'm getting the following error code:
(OAuthException - #2200) (#2200) callback verification failed: Received HTTP code 502 from proxy after CONNECT"
What do I miss?
The callback url is https://127.0.0.1:8989/ and I have a TcpListener running on the port, which does not seem to get any response/request incoming...
The application is a C# console application, so no fancy asp.net stuff or something. I'm using the Facebook .net SDK.
Should I FacebookClient.VerifyPostSubscription() or anything else that I missed out?? Maybe the SDK wraps a handle?
So the answer I'm looking for is:
- How do I create/add a subscription for feeds of a facebook page, using the .net SDK on a windows console project??
UPDATE:
I changed the loopback with a domain name, that I the NAT to my target machine, and now I actually get some encrypted data on my TcpListener!
So, the question now is, how do I respond correctly to this received respons, only by using a Tcp Client??
How you have to respond is exactly outlined in the docs you linked:
https://developers.facebook.com/docs/graph-api/real-time-updates/v2.4#setupget
It's not really clear what you mean with "TCP listener". You need to have some logic why can send HTTP responses to the Facebook servers, otherwise your service will be disregarded after some time, meaning no updates will be send.
Typically, this is implemented as a script/application in a web/application server.
Please note: The "C# SDK" is a third-party SDK and not officially supported by FB.
I'm trying to test talking to apple's push notification sandbox server.
I made a certificate following this link
(enabled push notification, requested certificate authority, uploaded, generated cert, export p12)
I made a sample C# console application that looks like the following
PushBroker push = new PushBroker();
var appleCert = File.ReadAllBytes(#"devapns.p12");
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;
push.RegisterAppleService(new ApplePushChannelSettings(false,appleCert,"password"));
push.QueueNotification(new AppleNotification()
.ForDeviceToken(token)
.WithPasskitUpdate());
push.StopAllServices(waitForQueuesToFinish: true);
When I run I get
The maximum number of Send attempts was reached
The version of PushSharp I'm currently using is 2.2.1.0
Is there something else I need to do? Do I need to enable SSL somewhere? Is my certificate not properly installed on my local machine. I'm not sure where I am going wrong.
NOTE: the p12 file is about 3KB
I installed the development certificate on my local computer just for testing when running this console application
UPDATE:
I managed to get notifications successfully being sent to apns. However, the only problem is that passes do not update on the user device. According to this link, my webservice is to get a list of valid serial numbers once invoked by the device after receiving a passbook update notification from APNS. However, this never happens.
It seems as if I can successfully send my notification to the Apple Notification Service, but from there the apns cannot send it to the device. Any thoughts?
Right now I am signing the pass and sending a notification to APNS using the same pass type ID certificate.
So I was finally able to update a pass in passbook using APNS. It was an arduous process and there were many different things I didn't take into account. Here are a couple things to keep in mind.
Be sure you use the same .p12 file when signing the pass and using pushsharp. (I had originally used a different .p12 associated with regular push notifications). So the link I originally posted in the question is a tad bit misleading, you would follow those steps for regular push notifications. But for passbook notifications, you need use the .p12 file associated with your Pass Type ID
In PushSharp, be sure to disable the production/sandbox certificate check. There is no sandbox environment for passbook, so everything should point to production. In this line, add an extra true parameter to disable the check
push.RegisterAppleService(new ApplePushChannelSettings(false,appleCert,"password", true));
Be sure you aren't using a test device when testing. Also you cannot use the simulator
The push token you receive is different than the DeviceIDToken you would receive when registering for regular push notifications. The push token is passbook exclusive
Ensure the proper certificates are installed on your server. For example I had to install the pass type ID certificate
Do a telnet feedback.push.apple.com 2196 to ensure you can hit the apns server
If I do the following:
UdpClient c = new UdpClient();
c.Connect(new System.Net.IPEndPoint(IPAddress.Parse("69.65.85.125"), 9900));
c.Send(new byte[] { 1,2,3,4,5 }, 5);
then I will be sending a packet to my router then my router will send that packet to the ip "69.65.85.125".
If I where to capture that packet on the computer that has the ip "69.65.85.125" I will be able to see the port that was oppened by the router (client.RemoteEndpoint). How will it be possible to see that information without capturing the packet at the other enpoint? Is there a way to query the router?
If your router supports it you can query it via UPnP. Here is a wrapper library for UPnP I found for .NET, I have never used it so I cant give you any advice if it is good or not.
Look at the ComponetsTest program for example code in the zip for the library. You will need to reference the UPnP documentation to find out what calls you will need to make to the service.
From the message board of the library of someone asking a how to find port mappings.
The WANPPPConnection and WANIPConnection services have actions called
GetSpecificPortMappingEntry, simply call this iterating through the
indexes from 0 until an error is returned, each call will return
another UPnP port mapping, you can also get the static mappings with a
different service.
In order to get the public IP, the remote device should respond by sending a UDP packet back to you that contains the IP address and port it saw. This is one of the most fundamental concepts behind a STUN server, commonly used in UDP hole-punching algorithms.
There are several free STUN servers available that do exactly this. Send one of them a "binding" request, and you will get back a response with your public IP address and port.
stun.l.google.com:19302
stun1.l.google.com:19302
stun2.l.google.com:19302
stun3.l.google.com:19302
stun4.l.google.com:19302
stun01.sipphone.com
stun.ekiga.net
stun.fwdnet.net
stun.ideasip.com
stun.iptel.org
stun.rixtelecom.se
stun.schlund.de
stunserver.org
stun.softjoys.com
stun.voiparound.com
stun.voipbuster.com
stun.voipstunt.com
stun.voxgratia.org
stun.xten.com
If you are truly interested in doing proper UDP hole-punching, check out ICE (Interactive Connectivity Establishment). It's a brilliant algorithm that uses STUN and another protocol called TURN to guarantee a successful connection between peers. (Apple uses it for Facetime video calls, among others.)
If you're interested, the company I work for has developed a product called IceLink that uses ICE/STUN/TURN to establish direct data streams between peers. SDKs are available for .NET, Mac, iOS, Android, Java, Windows Phone, Windows 8, Unity, Xamarin, and more, and it even includes full support for WebRTC audio/video streams.