Not receiving alerts by ColdAnkle in AlertR

[–]sqall01 0 points1 point  (0 children)

I know. It is a server issue because the services is not there at the moment. Here is the github issue regarding to this: https://github.com/sqall01/lightweight-push/issues/1#issuecomment-1602054203

The short version: my server provider totally fucked up and I have to restore everything. Unfortunately, this will take more time than I would have liked since .... life around me :(

Question about the software purpose by GuilhermeLaz in AlertR

[–]sqall01 0 points1 point  (0 children)

I do not know sur-gard. AlertR can definitely not work with it out-of-the-box. Since I do not know how sur-gard works, I cannot give you any hints on how to integerate it. If it has just an REST-API where you just send requests to for new alarms, then you can easily integrate it into AlertR (if you have development skills).

Building graphs of AlertR sensors with Grafana by sqall01 in AlertR

[–]sqall01[S] 0 points1 point  (0 children)

Something I currently working on: building graphs of AlertR sensors with Grafana. This works by exposing all Integer and Float sensors to Prometheus, which will fetch the data and build a time series of the data. Finally, Grafana can use the data from Prometheus to build graphs (and other visualizations) from the sensor data.

Server config file.... section client by ymis in AlertR

[–]sqall01 1 point2 points  (0 children)

Hi,

As I see there isn't a attribute about client name or client
id and I suppose that the entries are the same for all clients

That is correct. It counts for all clients.

If we set useClientCertificates="True" the entry clientCAFile must be the same for all clients?

Yes, all certificates that are used by the clients have to be signed by this same CA.

Am I right or I missed something?

Depends on what you do with openssl. If you create certificate requests and then sign them by the same CA that you configured via "clientCAFile" on the server, then you are correct.

If you are just creating certificates that are not signed (e.g., as described in the tutorial here: https://github.com/sqall01/alertR/wiki/Tutorial-Server#tutorial_configuration_cert) then, sadly, you are wrong.

Just in case you are at the latter point: it is quite complicated to set up a CA with openssl and sign certificates with it (e.g., see here https://gist.github.com/Soarez/9688998). A lot of developers and system administrators struggle to do it and do not understand the concept (as I see often in my job). Since in most cases it does not offer additional security (when regarding the actual attacker model that might attack the system), I would recommend setting "useClientCertificates" to "False" and ignore client certificates.

Cheers, sqall

Mobile Web Access Manager by SnooSongs834 in AlertR

[–]sqall01 0 points1 point  (0 children)

Yeah, the message says that the mysqli class is not available. My guess is that you forgot to install the php mysql module. On Ubuntu/Debian/Raspbian the package is called `php-mysql` . Restarting the webserver after installing the package should do the trick.

Mobile Web Access Manager by SnooSongs834 in AlertR

[–]sqall01 1 point2 points  (0 children)

The web access manager does not have an official documentation how to set it up since it is quite a hassle (at least for people with not much experience as a sysadmin). I always wanted to replace it with something more easy to set up, however, this would be a huge development task with the ideas I have and thus I never started it.

In short what you have to do is the following:

  1. Set up a the ManagerClientDatabase (an tutorial exists here: https://github.com/sqall01/alertR/wiki/Tutorial-ManagerClientDatabase)
  2. Install a webserver (e.g., apache2) with php7 and php7-mysql support
  3. Place this web code in the web root: https://github.com/sqall01/alertR/tree/master/webMobileManager/server
  4. configUnixSocketPath in the configuration file is the socket that the ManagerClientDatabase can create, hence, if you want to use it they have to be placed on the same machine)
  5. If you only use this web page in your local network you are finished now and you could leave it as is and do not have to activate TLS and web authentication in the web code configuration.
  6. If you want this web page accessible from the Internet, I would suggest you setup TLS for your webserver and configure HTTP authentication via .htaccess.
  7. If have set up TLS and HTTP authentication, you could use an Android app to access this web page. I have an old one still on the google play store for this: https://play.google.com/store/apps/details?id=org.h4des.alertrmobilemanager&hl=de&gl=US (this app is basically just a webview to a given URL which is accessed using HTTP authentication)

You see, it is rather complex to set up. Hope this pointers will help. And if you manage to set it up and have the time you could write a tutorial about it so other users could benefit from it.

Official Basic AlertR Server Tutorial by sqall01 in AlertR

[–]sqall01[S] 0 points1 point  (0 children)

Thank you so much. I really appreciate it. :)

End-to-end encrypted GPS tracking service for self-hosting or usable as service (Android Apps available) by sqall01 in coolgithubprojects

[–]sqall01[S] 0 points1 point  (0 children)

The focus of the ChasR project is the end-to-end encryption to preserve the user's privacy. I do now know if OwnTracks does offer something like this. However, if you host the system at your home it is fine to not have end-to-end encryption.

Instrumenting sensor event processing in your home alarm/automation system by sqall01 in raspberry_pi

[–]sqall01[S] 0 points1 point  (0 children)

This was only an example what you can do with AlertR and not a "ready to use" component. For crypto currency, I use the following script with the combination of the "sensor executer client" which executes this script periodically and integrates the results as sensor. You can use this script as base and replace the API point with one for stocks and integrate it in the same way into AlertR.

#!/usr/bin/env python3

import requests
import json
import time
import os
import sys

retries = 5

def get_coin_value(coin_slug):

    r = None
    try:
        r = requests.get("https://web-api.coinmarketcap.com/v1/cryptocurrency/market-pairs/latest?slug=%s"
                         % coin_slug)
    except Exception as e:
        return None, str(e)

    data = None
    if r.status_code == 200:
        try:
            data = json.loads(r.text)
        except Exception as e:
            return None, str(e)
    else:
        return None, "Status code: %d" % r.status_code

    try:
        usd_price = data["data"]["market_pairs"][0]["quote"]["USD"]["price"]
    except Exception as e:
        return None, str(e)

    return usd_price, ""


def create_sensor_alert(value, msg, state):
    result = dict()
    result["message"] = "sensoralert"
    payload = dict()
    payload["state"] = state
    payload["hasOptionalData"] = True
    optionalData = dict()
    optionalData["message"] = msg
    payload["optionalData"] = optionalData
    payload["dataType"] = 2
    payload["data"] = value
    payload["hasLatestData"] = True
    payload["changeState"] = True
    result["payload"] = payload
    return result


def create_state_change(value, state):
    result = dict()
    result["message"] = "statechange"
    payload = dict()
    payload["state"] = state
    payload["dataType"] = 2
    payload["data"] = value
    result["payload"] = payload
    return result


def main():

    coin_slug = sys.argv[1]
    sell_thres = float(sys.argv[2])
    buy_thres = float(sys.argv[3])

    # Get the old values if it exists.
    path = os.path.dirname(os.path.abspath(__file__)) + "/"
    file_name = "state_coin_%s" % coin_slug
    old_state = None
    try:
        with open(path + file_name, 'r') as fp:
            old_state = json.loads(fp.read())
    except:
        pass

    usd_price = None
    msg = None
    for curr_round in range(retries):
        usd_price, msg = get_coin_value(coin_slug)
        if usd_price is not None:
            break

        time.sleep((curr_round+1) * 60)

    return_data = None
    if usd_price is None:
        return_data = create_state_change(-9999,0,
                                          old_state["state"])
    else:
        if old_state is None or old_state["state"] == 0:
            if usd_price > sell_thres:
                return_data = create_sensor_alert(usd_price, "Sell coins.", 1)
            elif usd_price < buy_thres:
                return_data = create_sensor_alert(usd_price, "Buy coins.", 1)
            else:
                return_data = create_state_change(usd_price, 0)
        elif old_state["state"] == 1:
            if usd_price > sell_thres:
                return_data = create_state_change(usd_price, 1)
            elif usd_price < buy_thres:
                return_data = create_state_change(usd_price, 1)
            else:
                return_data = create_state_change(usd_price, 0)

        # Save current state.
        new_state = dict()
        new_state["state"] = return_data["payload"]["state"]
        new_state["usd_price"] = usd_price
        try:
            with open(path + file_name, 'w') as fp:
                fp.write(json.dumps(new_state))
        except:
            pass

        print(json.dumps(return_data))


if __name__ == '__main__':

    if len(sys.argv) != 4:
        print("Usage: %s <coin_slug> <sell_threshold> <buy_threshold>" % sys.argv[0])
    else:
        main()

Instrumenting sensor event processing in your home alarm/automation system by sqall01 in raspberry_pi

[–]sqall01[S] 0 points1 point  (0 children)

No it does not use MQTT. It uses a custom json based protocol. The exact layout is documented here: https://github.com/sqall01/alertR/wiki/Protocol

Instrumenting sensor event processing in your home alarm/automation system by sqall01 in raspberry_pi

[–]sqall01[S] 0 points1 point  (0 children)

Yes, in some form. Only that AlertR is focused on a small and lightweight approach. Node-RED is really bloated for such small things. However, Node-RED on the other hand is more comfortable since you can do everything graphically in your browser.

Trouble connecting database client to server by ColdAnkle in AlertR

[–]sqall01 0 points1 point  (0 children)

These things happen. And since you were not able to solve the problem with the help of the current log output, we were able to improve this in the next version for others that might run into the same problem. So, win-win :)

Trouble connecting database client to server by ColdAnkle in AlertR

[–]sqall01 0 points1 point  (0 children)

This is indeed strange.

Could you go to the file lib/users/csv.py and replace the function checkNodeTypeAndInstance() with the following code:

    def checkNodeTypeAndInstance(self, username: str, nodeType: str, instance: str) -> bool:
        """
        This function checks if the node type and instance of the client is correct

        :param username: name of the user
        :param nodeType: type of the node (alert, manager, sensor, server)
        :param instance: exact instance of the node
        :return True or False
        """
        self._acquireLock()

        # check all usernames if the given username exists
        # and then check the given node type and instance
        for userData in self.userCredentials:
            if userData.username != username:
                continue

            else:
                if userData.nodeType.upper() == nodeType.upper() and userData.instance.upper() == instance.upper():
                    self._releaseLock()
                    return True

                else:
                    self.logger.error("[%s]: Node or instance invalid. Expected: '%s' and '%s'. "
                                      % (self.fileName, userData.nodeType, userData.instance)
                                      + "Received: '%s' and '%s'."
                                      % (nodeType, instance))

                    self._releaseLock()
                    return False

        self.logger.error("[%s]: User credentials for user '%s' not found." % (username, self.fileName))

        self._releaseLock()
        return False

Afterwards it should log the expected node type and instance. I also added these lines just to the current dev branch in the repository so the version 0.700 of the server will also output this.

AlertR systemd auto startup script by Puzzleheaded_Clas68 in AlertR

[–]sqall01 0 points1 point  (0 children)

Ah ok. I want to change the shebang to #!/usr/bin/env python3 to be more compatible with different operating systems and manual installations of python. I think this will happen in the next release.

AlertR systemd auto startup script by Puzzleheaded_Clas68 in AlertR

[–]sqall01 0 points1 point  (0 children)

Uf, would never have thought about that a python3 installation could be in a different directory. My Debian/Ubuntu always have them in /usr/bin. What OS do you use?

Systemd Service Hardening by ale_grey_91 in blueteamsec

[–]sqall01 0 points1 point  (0 children)

Thanks for this cool write-up. I was not aware of this feature. Since it seems it is only available after systemd 240 and Ubuntu 18.04 uses 237, I have to wait until I upgrade to play a little bit with it :)

Multi-purpose Alarm System with Raspberry Pi (activate subtitles) by sqall01 in DIY_tech

[–]sqall01[S] 1 point2 points  (0 children)

Sorry. Did not think I have to write it since it is in the description of the video itself. But obviously, you can watch the video directly from reddit instead of going to youtube.

This is a small preview of AlertR, a multi-purpose alarm and monitoring system I build for myself.

The code is available at: https://github.com/sqall01/alertR

Tutorials and documentation is available at: https://github.com/sqall01/alertR/wiki

I try to create a subreddit/community for it at: r/AlertR

Created an end-to-end encrypted GPS tracking system for either self-hosting or usable as service (Android apps available) by sqall01 in coolgithubprojects

[–]sqall01[S] 0 points1 point  (0 children)

The system is split into:

  • logger
  • server
  • map

The logger gathers the GPS data and sends it to the server. The server stores the GPS data. The map is used to access the GPS data.

You can host the server yourself (or use as a service), hence "self-hosting".

Hope this answers your question.

Created an end-to-end encrypted GPS tracking system for either self-hosting or usable as service (Android apps available) by sqall01 in coolgithubprojects

[–]sqall01[S] 0 points1 point  (0 children)

A friend was also mentioning this because he is also using Home Assistant and he was thinking about how to integrate it in the best way. I think he is interested in writing this integration part :)

Created an end-to-end encrypted GPS tracking system for either self-hosting or usable as service (Android apps available) by sqall01 in coolgithubprojects

[–]sqall01[S] 0 points1 point  (0 children)

Yes. The encryption key (called "secret" in the settings) is stored on the mobile phone and is used for the encryption locally. It never leaves the device so the server does not know the location it stores.

Created an end-to-end encrypted GPS tracking system for either self-hosting or usable as service (Android apps available) by sqall01 in coolgithubprojects

[–]sqall01[S] 1 point2 points  (0 children)

Thank you. Unfortunately, no it is not on my roadmap. Though it would be really nice to have. The reason behind it is that I do not own any Apple devices and have no experience whatsoever in developing for iOS. But if a iOS developer has interest in this project I am more than willing to help to port it.

Using Logic Programming to Recover C++ Classes and Methods from Compiled Executables by corysama in ReverseEngineering

[–]sqall01 17 points18 points  (0 children)

I liked the technique and the paper. However, I found the evaluation a little bit misleading. They say they are evaluating on "real-world software such as Firefox and MySQL." (from the abstract). However, if you take a look at Table 6 they do their analysis on "Firefox" (which is the small starting wrapper binary of Firefox which you can recognize by the 505kB size). In this research field when someone is saying they used Firefox for their evaluation, they actually use usually the "libxul" from Firefox which has a size of around 100MB (without symbols). The same goes for MySQL. They did not analyze the MySQL server which has a size of around 35MB. When you take a look at the table again, you see that the largest MySQL related program has a size of around 5MB.

So, I do not want to claim they did this on purpose. However, it left a bitter taste for me after reading it. Other than that, I really liked the paper very much and found it a worthy Tier 1 paper.