Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abruf von Punkten nicht möglich #1

Closed
uwe-schwarz opened this issue May 14, 2016 · 23 comments
Closed

Abruf von Punkten nicht möglich #1

uwe-schwarz opened this issue May 14, 2016 · 23 comments
Assignees

Comments

@uwe-schwarz
Copy link

Fehler: Payback-Punkte.lua:171: bad argument #1 to 'request' (string expected, got no value)

Scheinbar bekommt er den div mit "secondary-nav tracking-event-module" nun als "secondary-nav pull-right tracking-event-module" zurück, vermutlich weil irgendwo die mobile Seite ausgewählt wird. Ich kann es leider nicht weiter debuggen, da ich keine Version mit deaktivierbarer Signaturprüfung habe.

@philwo
Copy link

philwo commented May 14, 2016

Ich habe das gleiche Problem seit ein paar Tagen.

"pull-right" zum xpath in Zeile 171 hinzuzufügen bringt einen zwar weiter, löst das Problem aber noch nicht ganz - dann findet er in Zeile 208 die pointRangeForm nicht...

@jgoldhammer
Copy link
Owner

Hallo @uwe-schwarz und @philwo ,

ich kann das Problem bei mir nicht reproduzieren.
Könnt ihr mir daher eure Logfiles bereitstellen?

Danke,
Jens

@uwe-schwarz
Copy link
Author

Das sollte das komplette Log sein.
payback.txt

@jgoldhammer
Copy link
Owner

Habt ihr schon meine Version hier ausgetestet??
29e0ecc

@philwo - kannst du diese Version bitte testen?
Hintergrund:
Auf der Seite https://moneymoney-app.com/extensions/ ist noch eine ältere Version online.
Falls diese Version funktioniert, werde ich Herrn Haller von MoneyMoney bitten, die neue Version in die Seite https://moneymoney-app.com/extensions/ aufzunehmen.

Danke...

@jgoldhammer
Copy link
Owner

Hi @uwe-schwarz,

danke für die Bereitstellung des Logfiles. Ich tippe ganz stark, dass die neue Pre-Release Version 1.1 (https://github.com/jgoldhammer/moneymoney-payback/releases/tag/v1.1) dein Problem lösen wird.
Da du diese Version nicht austesten kannst, werde ich die Version bei Herrn Haller einreichen. Ich update das Ticket, wenn die neue Version bei moneymoney-app auf der Extensionsseite erschienen ist. Ich bitte noch um etwas Geduld.

Danke,
Jens

@jgoldhammer jgoldhammer self-assigned this May 14, 2016
@jgoldhammer
Copy link
Owner

Die neue Version ist online:
https://moneymoney-app.com/extensions/Payback-Punkte.lua

Bitte um Rückmeldung- danke!

@uwe-schwarz
Copy link
Author

Das ging schnell, nun scheitert es aber an der nächsten Stelle: Payback-Punkte.lua:208: bad argument #1 to 'request' (string expected, got no value)

@philwo
Copy link

philwo commented May 14, 2016

Hi @jgoldhammer - vielen Dank für die neue Version!

Ich habe den gleichen Fehler wie @uwe-schwarz:
Payback-Punkte.lua:208: bad argument #1 to 'request' (string expected, got no value)

Brauchst du ein Logfile, oder kannst du das bei dir so reproduzieren?

@jgoldhammer
Copy link
Owner

Hallo @philwo, hallo @uwe-schwarz ,

ich kann mir den Fehler bisher nicht erklären.
Könnt ihr euch bitte direkt in paypack über die Weboberfläche einloggen und bitt im Chrome über Developer Tools oder über Firefox prüfen, ob die pointRangeForm-ID an der Form zum Absenden des Formulars im HTML existiert?

image

Bitte schreibt mir außerdem die URL vom Browser, wenn ihr eingeloggt seid...

image

Im Logfile ist das leider nicht drin...

Danke,
Jens

@uwe-schwarz
Copy link
Author

Im Browser (sowohl Safari als auch Chrome) ist das bei mir wie vorher (also ohne das pull-right und auch mit dem pointRangeForm), ich kann später mal versuchen MoneyMoney dazu zu überreden einen mitmproxy zu benutzen und dann kann ich dir mehr Infos geben. Die URL ist bei mir auch "https://www.payback.de/pb/punktekonto/id/13598/".

@uwe-schwarz
Copy link
Author

So wie das für mich aussieht funktioniert der Login nicht.

Erster Request: curl -H 'host:www.payback.de' -H 'Connection:keep-alive' -H 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8' -H 'User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17' -H 'Referer:https://www.payback.de/pb/authenticate/id/713416/#loginSecureTab' -H 'Accept-Language:de-de' -H 'Accept-Encoding:gzip, deflate' 'https://www.payback.de/pb/authenticate/id/713416/'
-> liefert ein 200

Zweiter Request: curl -H 'host:www.payback.de' -H 'Content-Type:application/x-www-form-urlencoded' -H 'Origin:https://www.payback.de' -H 'Cookie:JSESSIONID=xxx; plg_sec=xxx; pd_cookie=''; notepad=x; __utma=x; __utmb=x; __utmc=x; __utmt=x; __utmv=x; __utmz=x; ga=x; gat=x; BIGipServerpool_pbde_prod_www=xxx' -H 'Content-Length:200' -H 'Connection:keep-alive' -H 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8' -H 'User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17' -H 'Referer:https://www.payback.de/pb/authenticate/id/713416/#loginSecureTab' -H 'Accept-Language:de-de' -H 'Accept-Encoding:gzip, deflate' -X POST 'https://www.payback.de/pb/ww/authenticate.password.action' --data-binary 'model.alias=xxx&password=xxx&__checkbox_usePermLogin=true&usePermLogin=true&token=xxx&did=xxx&page_id=xxx&language=&cid=xxx&secToken='
(alles was nach session oder security Daten ausgesehen hat hab ich nun mal mit "xxx" ersetzt)
-> da kommt ein 302 auf https://www.payback.de/pb/authenticate/id/713416/#loginSecureTab
und ein Cookie, der nicht so prickelnd aussieht:
Set-Cookie: bbst="VERSION:==.1:,,.MEMBER:==.unknown:,,.LEVEL:==.strong:,,.CREATED:==.2016-05-14-14:,,.TOKEN:==.xxx"; Version=1; Max-Age=1800; Expires=Sat, 14-May-2016 12:41:46 GMT; Path=/; Secure; HttpOnly

Kannst du damit was anfangen oder soll ich dir mehr zur Verfügung stellen?

@uwe-schwarz
Copy link
Author

Ich habe gerade mal mein Passwort geändert und die Kontenliste in MoneyMoney neu abgefragt, da kommt folgende Fehlermeldung: Payback-Punkte.lua: expected string for 'account.accountNumber'

@jgoldhammer
Copy link
Owner

Hallo Uwe,
danke für deine Unterstützung. Ich kann den Fehler JETZT bei mir auch reproduzieren (evtl. durch die neue Version 1.1)- ich kümmere mich in den nächsten Tagen drum.

VG,
Jens

@jgoldhammer
Copy link
Owner

Hallo zusammen,

ein kurzer Zwischenstand nach Debugging mit mitmproxy und der Webseite im Chrome:

  • Authentifizierung am payback Server über http request im moneymoney (lua http) schlägt fehl, obwohl die scheinbar "richtigen" Nutzdaten im Body mitgesendet werden. Ein Vergleich der Daten zeigt nur unterschiedliche Ids bei dem Token (ich denke, so etwas wie CSRF)
  • es gibt eine Reihe von Cookies, die über den Browser zusätzlich gesendet werden (UserID1, manchmal eine JSESSIONID_BB und mbox). Zusätzlich noch ein paar Tracking-Cookies...

image

Ich versuche jetzt herauszufinden,wie die Cookies erzeugt werden- z.B. UserID1 - das Cookie wird nicht vom Server gesetzt, jedenfalls sehe ich das in den Responses nicht. Gleichzeitig finde ich aber keinen clientseitigen Code zum Erzeugen der UserID1...

Habt ihr noch Ideen, wie ich das herausbekomme?

BTW, Payback schützt seine User nicht gegen Session Fixation (https://de.wikipedia.org/wiki/Session_Fixation)- die JSESSIONID wird beim Einloggen nicht erneuert...

@jgoldhammer
Copy link
Owner

Hier noch die Formdaten:

image

@jgoldhammer
Copy link
Owner

Die UserID1 wird über einen Request zu https://mpm.payback.de/js?wp_id=XXX generiert und wird scheinbar auch fürs Advertising benutzt...

@uwe-schwarz
Copy link
Author

Gibt es hierzu was neues, @jgoldhammer?

@gharlan
Copy link

gharlan commented Apr 27, 2017

Gibt es hierzu was neues

Jetzt ja. Zumindest bei mir funktioniert es plötzlich wieder.

@jgoldhammer
Copy link
Owner

Wow, bei mir leider nicht...

payback.lua:236: attempt to concatenate a nil value

@gharlan
Copy link

gharlan commented Apr 27, 2017

Ich war auch ganz überrascht. Hatte die Extension die ganze Zeit bei mir drin gelassen, und plötzlich kamen heute die ganzen fehlenden Umsätze rein.

Ich hatte damals auch (erfolglos) probiert, die Extension wieder zum laufen zu bringen, daher bin ich mir gerade nicht mehr sicher, ob bei mir nun noch Änderungen von mir drin sind, oder ob ich die wieder zurückgesetzt hatte.

Ich habe hier diese Version:

-- ---------------------------------------------------------------------------------------------------------------------
--
-- MoneyMoney Web Banking Extension
-- http://moneymoney-app.com/api/webbanking
--
--
-- The MIT License (MIT)
--
-- Copyright (c) 2012-2015 MRH applications GmbH
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
--
-- ---------------------------------------------------------------------------------------------------------------------

-- ---------------------------------------------------------------------------------------------------------------------
--
-- Get portfolio of Payback online account.
--
-- ATTENTION: This extension requires MoneyMoney version 2.2.2 or higher
--
-- ---------------------------------------------------------------------------------------------------------------------


-- ---------------------------------------------------------------------------------------------------------------------
-- Common MoneyMoney extension informations
-- ---------------------------------------------------------------------------------------------------------------------

WebBanking {
    version = 1.1,
    country = "de",
    url = "https://www.payback.de/pb/authenticate/id/713416/",
    services    = {"Payback-Punkte"},
    description = string.format(MM.localizeText("Get points of %s"), "Payback account")
}

-- ---------------------------------------------------------------------------------------------------------------------
-- Helper functions
-- ---------------------------------------------------------------------------------------------------------------------

local function strToAmount(str)
    -- Helper function for converting localized amount strings to Lua numbers.
    print("raw value: ".. str)
    local convertedValue = string.gsub(string.gsub(string.gsub(str, " .+", ""), "%.", ""), ",", ".")
    print("converted value " .. convertedValue)
    return convertedValue
end

-- ---------------------------------------------------------------------------------------------------------------------

local function strToAmountWithDefault(str, defaultValue)
    -- Helper function for converting localized amount strings to Lua numbers with a default value.
    local value = strToAmount(str)
    if value == nil or value == "" then
        value = defaultValue
    end
    return value
end

-- ---------------------------------------------------------------------------------------------------------------------

local function strToDate(str)
    -- Helper function for converting localized date strings to timestamps.
    local d, m, y = string.match(str, "(%d%d)%.(%d%d)%.(%d%d%d%d)")
    if d and m and y then
        return os.time { year = y, month = m, day = d, hour = 0, min = 0, sec = 0 }
    end
end

-- ---------------------------------------------------------------------------------------------------------------------

local function printElementWithPrefix(prefix, element)
    -- Helper function  for debugging HTML elements with a prtinable prefix
    if element:children():length() >= 1 then
        element:children():each(function(index, element2)
            local newPrefix = prefix .. "-" .. index
            print(newPrefix .. "=" .. element2:text())
            printElementWithPrefix(newPrefix, element2)
        end)
    end
end

-- ---------------------------------------------------------------------------------------------------------------------


local function strToFullDate (str)
    -- Helper function for converting localized date strings to timestamps.
    local d, m, y = string.match(str, "(%d%d).(%d%d).(%d%d%d%d)")
    return os.time{year=y, month=m, day=d}
end

local function printElement(element)
    -- Helper function  for debugging HTML elements
    printElementWithPrefix('0', element)
end


-- ---------------------------------------------------------------------------------------------------------------------
-- The following variables are used to save state.
-- ---------------------------------------------------------------------------------------------------------------------

local connection
local overview_html


-- ---------------------------------------------------------------------------------------------------------------------
--
-- MoneyMoney API Extension
--
-- @see: http://moneymoney-app.com/api/webbanking/
--
-- ---------------------------------------------------------------------------------------------------------------------

function SupportsBank(protocol, bankCode)
    -- Using artificial bankcode to identify the DWS Investments group.
    return bankCode == "Payback-Punkte" and protocol == ProtocolWebBanking
end

-- ---------------------------------------------------------------------------------------------------------------------

function InitializeSession(protocol, bankCode, username, customer, password)

    print("InitializeSession with " .. protocol .. " connecting " .. url .. "with ".. username)
    MM.printStatus("Start to login...")

    -- Create HTTPS connection object.
    connection = Connection()
    connection.language = "de-de"

    -- Fetch login page.
    local loginPage = HTML(connection:get(url))

    -- Fill in login credentials.
    loginPage:xpath("//*[@id='aliasInputSecure']"):attr("value", username)
    loginPage:xpath("//*[@id='passwordInput']"):attr("value", password)

    MM.printStatus("parameters filled in ");

    -- Submit login form.
    local request = connection:request(loginPage:xpath("//input[@id='loginSubmitButtonSecure']"):click())

    MM.printStatus("request " ..request)
    overview_html = HTML(request)

    -- Check for failed login.
    local failure = overview_html:xpath("//*[@id='errorNotification']")
    if failure:length() > 0 then
        print("Login failed. Reason: " .. failure:xpath("//*p[@class='MsoNormal']"))
        MM.printStatus("Login failed...");
        return LoginFailed
    end

    MM.printStatus("Login success- go to correct paypack page ");

    -- hard coded point url ...
    overview_html = HTML(connection:get("https://www.payback.de/pb/punktekonto/id/13598/"))

    print("Session initialization completed successfully.")
    MM.printStatus("Login successfull...")
    return nil
end

-- ---------------------------------------------------------------------------------------------------------------------

function ListAccounts(knownAccounts)

    local accountNumber = overview_html:xpath("//p[text()='Kundennummer:']/span"):text();
    -- Supports only one account
    local account = {
        owner = overview_html:xpath("//*/p[@class='welcome-msg']/strong"):text(),
        name = "Paypack Punkte Konto (" .. accountNumber .. ")",
        accountNumber = accountNumber,
        portfolio = false,
        currency = "EUR",
        type = AccountTypeUnknown
    }

    return { account }
end

-- ---------------------------------------------------------------------------------------------------------------------

function RefreshAccount(account, since)
    local transactions = {}

    -- the datefields can be filled directly
    overview_html:xpath("//input[@id='date1']"):attr("value", os.date("%d.%m.%Y", since))
    overview_html:xpath("//input[@id='date2']"):attr("value", os.date("%d.%m.%Y"))

    MM.printStatus("Fill in date ranges")

    print("Submitting transaction search form for " .. account.accountNumber)
    overview_html = HTML(connection:request(overview_html:xpath("//form[@id='pointRangeForm']"):submit()))

    -- Get paypack points from text next to select box
    local balance = overview_html:xpath("//span[@id='serverPoints']"):text()
    -- eleminate the dot in the point number and divide it with 100 to get the euro equivalent
    balance = string.gsub(balance,"%.","")/100

    MM.printStatus("balance " .. balance)

    local firstPage =true;

    repeat
        local noMorePages = true;

        -- Check if the HTML table with transactions exists.
        if overview_html:xpath("//table[@class='mypoints']/tbody/tr[1]/td[1]"):length() > 0 then

            -- Extract transactions.
            overview_html:xpath("//table[@class='mypoints']/tbody/tr[position()>0]"):each(function (index, row)
                local columns = row:children()
                local transaction = {
                    valueDate   = strToFullDate(columns:get(1):text()),
                    bookingDate = strToFullDate(columns:get(1):text()),
                    name        = columns:get(2):text(),
                    purpose     = columns:get(3):text() .. " : " .. columns:get(4):text(), true,
                    currency    = "EUR",
                    amount      = strToAmount(columns:get(4):text(), true)/100
                }

                table.insert(transactions, transaction)
            end)


            local linkCounter
            if firstPage then
                linkCounter = 1
            else
                linkCounter = 2
            end


            local nextPageLink = overview_html:xpath("//div[@class='pager-list']/a[".. linkCounter .."]");

            -- check website for more pages to extract transactions for
            if  nextPageLink:length()> 0 then
                local link = overview_html:xpath("//div[@class='pager-list']/a[".. linkCounter .."]")
                overview_html = HTML(connection:request(overview_html:xpath("//div[@class='pager-list']/a[".. linkCounter .."]"):click()))
                noMorePages = false;
                firstPage=false;
                MM.printStatus("Getting more transactions...")
            end

        end
    until (noMorePages);

    -- Return balance and array of transactions.
    return {balance=balance, transactions=transactions, securities=nil}
end

-- ---------------------------------------------------------------------------------------------------------------------

function EndSession()

    -- Submit logout form.
    local logout_html = HTML(connection:request(overview_html:xpath("//a[@id='pbLogin']"):click()))

    print("Logged out successfully!")
end

-- SIGNATURE: MCwCFEi7zhrUhPNbur7MrkmyRnKlNOyLAhQae47rAv1jHMPSfjiORltSOUXyAg==

@gharlan
Copy link

gharlan commented Apr 27, 2017

Habe MoneyMoney in der Version 2.2.17 (284) Beta.

@gharlan
Copy link

gharlan commented Jul 30, 2017

Funktioniert weiterhin. Ich musste nun allerdings den Logout-Aufruf auskommentieren. Da wird umgeleitet zu https://www.payback.de/pb/id/314472/ und die Seite gibt dann einen 500er Fehler zurück. Dadurch bricht MoneyMoney dann aber ab.

Nach Auskommentieren funktioniert es aber wieder, es wird dann halt nicht korrekt ausgeloggt. Ist aber die Frage, ob das überhaupt notwendig ist.

@jgoldhammer
Copy link
Owner

Logout-Funktion funktioniert bei mir wieder und auch der Abruf mit Version 2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants