This file is indexed.

/usr/lib/nodejs/node-xmpp/xmpp/sasl.js is in libnode-node-xmpp 0.2.7-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
var crypto = require('crypto');
var querystring = require('querystring');

function selectMechanism(mechs) {
    if (mechs.indexOf("X-FACEBOOK-PLATFORM") >= 0)
        return new XFacebookPlatform();
    else if (mechs.indexOf("DIGEST-MD5") >= 0)
        return new DigestMD5();
    else if (mechs.indexOf("PLAIN") >= 0)
        return new Plain();
    else if (mechs.indexOf("ANONYMOUS") >= 0)
        return new Anonymous();
    else
        return null;
}
exports.selectMechanism = selectMechanism;

function Plain() {
    this.name = "PLAIN";
    this.auth = function() {
        return this.authzid + "\0" +
            this.authcid + "\0" +
            this.password;
    };
}

function XFacebookPlatform() {
    this.name = "X-FACEBOOK-PLATFORM";
    this.auth = function() {
        return "";
    };
    this.challenge = function(s) {
        var dict = querystring.parse(s);

        var response = {
            api_key: this.api_key,
            call_id: new Date().getTime(),
            method: dict.method,
            nonce: dict.nonce,
            session_key: this.session_key,
            v: "1.0"
        };

        var message = '';
        ['api_key', 'call_id', 'method', 'nonce', 'session_key', 'v'].forEach(function(v) {
            message += v + "=" + response[v];
        });
        
        response.sig = md5(message + this.secret_key, 'hex');
                
        return querystring.stringify(response);
    };  
}

function Anonymous() {
    this.name = "ANONYMOUS";
    this.auth = function() {
        return this.authzid;
    };
}

function DigestMD5() {
    this.name = "DIGEST-MD5";
    this.auth = function() {
        return "";
    };

    this.nonce_count = 0;
    this.getNC = function() {
        return rjust(this.nonce_count.toString(), 8, '0');
    };
    this.cnonce = generateNonce();
    this.challenge = function(s) {
        var dict = parseDict(s);
        if (dict.realm)
            this.realm = dict.realm;
        //require('sys').puts("dict: "+JSON.stringify(dict));

        var response;
        if (dict.nonce && dict.qop) {
            this.nonce_count++;
            var a1 = md5(this.authcid + ':' +
                         this.realm + ':' +
                         this.password) + ':' +
                             dict.nonce + ':' +
                             this.cnonce + ':' +
                             this.authzid;
            var a2 = "AUTHENTICATE:" + this.digest_uri;
            if (dict.qop == 'auth-int' || dict.qop == 'auth-conf')
                a2 += ":00000000000000000000000000000000";
            var responseValue = md5_hex(md5_hex(a1) + ':' +
                                        dict.nonce + ':' +
                                        this.getNC() + ':' +
                                        this.cnonce + ':' +
                                        dict.qop + ':' +
                                        md5_hex(a2)
                                       );
            response = {
                username: this.authcid,
                realm: this.realm,
                nonce: dict.nonce,
                cnonce: this.cnonce,
                nc: this.getNC(),
                qop: dict.qop,
                'digest-uri': this.digest_uri,
                response: responseValue,
                authzid: this.authzid,
                charset: 'utf-8'
            };
        } else if (dict.rspauth) {
            return "";
        }
        //require('sys').puts('response: '+JSON.stringify(response));
        return encodeDict(response);
    };
}

function parseDict(s) {
    var result = {};
    while (s) {
        var m;

        if ((m = /^(.+?)="(.*?[^\\])",(.*)/.exec(s))) {
            result[m[1]] = m[2];
            s = m[3];
        } else if ((m = /^(.+?)="(.*?[^\\])"$/.exec(s))) {
            result[m[1]] = m[2];
            s = m[3];
        } else if ((m = /^(.+?)=(.+?),(.*)/.exec(s))) {
            result[m[1]] = m[2];
            s = m[3];
        } else if ((m = /^(.+?)=(.+?)$/.exec(s))) {
            result[m[1]] = m[2];
            s = m[3];
        } else {
            s = null;
        }
    }
    return result;
}

function encodeDict(dict) {
    var s = "";
    for(k in dict) {
        var v = dict[k];
        if (v)
            s += ',' + k + '="' + v + '"';
    }
    return s.substr(1);  // without first ','
}

function rjust(s, targetLen, padding) {
    while(s.length < targetLen)
        s = padding + s;
    return s;
}

function md5(s, encoding) {
    var hash = crypto.createHash('md5');
    hash.update(s);
    return hash.digest(encoding || 'binary');
}

function md5_hex(s) {
    return md5(s, 'hex');
}

function generateNonce() {
    var result = "";
    for(var i = 0; i < 8; i++)
        result += String.fromCharCode(48 +
                                      Math.ceil(Math.random() * 10));
    return result;
}